2

这是我的代码:

public function TOTALCODE () 
{ 
if ($parentBlock = $this->getParentBlock()) 
{ 
$amount = __(number_format(Mage::getSingleton(’checkout/session’)->getQuote()->getGrandTotal(), 2, ‘,’, ‘.’)); 
$text = __(’€ %s (incl. 21% btw)’, $amount); 
$parentBlock->addLink($text, ‘checkout/cart’, $text, true, array(), 50,null,’class="top-link-cart"’); 
}

如何在不包括运费的情况下显示总计?

4

3 回答 3

2

在 Magento 1.8 中,sales_flat_quote - 表中似乎没有可用的运费。

我必须通过以下方式检索总数:

$totals = Mage::getSingleton('checkout/cart')->getQuote()->getTotals()

并检查:

$totalKeys = array('subtotal', 'shipping', 'tax', 'discount', 'grand_total');

foreach ($totalKeys as $totalKey) {
    if (isset($totals[$totalKey])) echo $totals[$totalKey]->getData('value');
}
于 2014-01-16T10:31:13.927 回答
2

嗯,做个计算。

$subtotal = Mage::getSingleton('checkout/session')->getQuote()->getGrandTotal() - Mage::getSingleton('checkout/session')->getQuote()->getShippingAmount()

于 2013-01-30T19:54:22.557 回答
1

您可以使用以下计算:

$grandTotal = Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal();
$shipping = Mage::getSingleton('checkout/cart')->getQuote()->getTotals()['shipping']->getValue();

$grandTotalWithoutShipping = $grandTotal - $shipping;
于 2016-02-18T13:57:00.313 回答