本文整理汇总了PHP中Mage_Sales_Model_Quote_Address::getTotalAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Address::getTotalAmount方法的具体用法?PHP Mage_Sales_Model_Quote_Address::getTotalAmount怎么用?PHP Mage_Sales_Model_Quote_Address::getTotalAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Address
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Address::getTotalAmount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
/**
* Update the address with totals data used for display in a total line,
* e.g. a total line in the cart.
*
* @param Mage_Sales_Model_Quote_Address
* @return self
*/
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$total = $address->getTotalAmount($this->getCode());
if ($total) {
$address->addTotal(['code' => $this->getCode(), 'title' => $this->_helper->__(self::TAX_TOTAL_TITLE), 'value' => $total]);
}
return $this;
}
示例2: _addSubtotalAmount
/**
* Add row total item amount to subtotal
*
* @param Mage_Sales_Model_Quote_Address $address
* @param Mage_Sales_Model_Quote_Item_Abstract $item
*
* @return Mage_Tax_Model_Sales_Total_Quote_Subtotal
*/
protected function _addSubtotalAmount(Mage_Sales_Model_Quote_Address $address, $item)
{
if ($this->_config->priceIncludesTax($this->_store)) {
$subTotal = $item->getRowTotalInclTax() - $item->getRowTax();
$baseSubTotal = $item->getBaseRowTotalInclTax() - $item->getBaseRowTax();
$address->setTotalAmount('subtotal', $address->getTotalAmount('subtotal') + $subTotal);
$address->setBaseTotalAmount('subtotal', $address->getBaseTotalAmount('subtotal') + $baseSubTotal);
} else {
$address->setTotalAmount('subtotal', $address->getTotalAmount('subtotal') + $item->getRowTotal());
$address->setBaseTotalAmount('subtotal', $address->getBaseTotalAmount('subtotal') + $item->getBaseRowTotal());
}
$address->setSubtotalInclTax($address->getSubtotalInclTax() + $item->getRowTotalInclTax());
$address->setBaseSubtotalInclTax($address->getBaseSubtotalInclTax() + $item->getBaseRowTotalInclTax());
return $this;
}
示例3: _roundTotals
/**
* Round the total amounts in address
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Tax_Model_Sales_Total_Quote_Tax
*/
protected function _roundTotals(Mage_Sales_Model_Quote_Address $address)
{
// initialize the delta to a small number to avoid non-deterministic behavior with rounding of 0.5
$totalDelta = 1.0E-6;
$baseTotalDelta = 1.0E-6;
/*
* The order of rounding is import here.
* Tax is rounded first, to be consistent with unit based calculation.
* Hidden tax and shipping_hidden_tax are rounded next, which are really part of tax.
* Shipping is rounded before subtotal to minimize the chance that subtotal is
* rounded differently because of the delta.
* Here is an example: 19.2% tax rate, subtotal = 49.95, shipping = 9.99, discount = 20%
* subtotalExclTax = 41.90436, tax = 7.7238, hidden_tax = 1.609128, shippingPriceExclTax = 8.38087
* shipping_hidden_tax = 0.321826, discount = -11.988
* The grand total is 47.952 ~= 47.95
* The rounded values are:
* tax = 7.72, hidden_tax = 1.61, shipping_hidden_tax = 0.32,
* shipping = 8.39 (instead of 8.38 from simple rounding), subtotal = 41.9, discount = -11.99
* The grand total calculated from the rounded value is 47.95
* If we simply round each value and add them up, the result is 47.94, which is one penny off
*/
$totalCodes = array('tax', 'hidden_tax', 'shipping_hidden_tax', 'shipping', 'subtotal', 'weee', 'discount');
foreach ($totalCodes as $totalCode) {
$exactAmount = $address->getTotalAmount($totalCode);
$baseExactAmount = $address->getBaseTotalAmount($totalCode);
if (!$exactAmount && !$baseExactAmount) {
continue;
}
$roundedAmount = $this->_calculator->round($exactAmount + $totalDelta);
$baseRoundedAmount = $this->_calculator->round($baseExactAmount + $baseTotalDelta);
$address->setTotalAmount($totalCode, $roundedAmount);
$address->setBaseTotalAmount($totalCode, $baseRoundedAmount);
$totalDelta = $exactAmount + $totalDelta - $roundedAmount;
$baseTotalDelta = $baseExactAmount + $baseTotalDelta - $baseRoundedAmount;
}
return $this;
}
示例4: _addSubtotalAmount
/**
* Add row total item amount to subtotal
*
* @param Mage_Sales_Model_Quote_Address $address
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return Mage_Tax_Model_Sales_Total_Quote_Subtotal
*/
protected function _addSubtotalAmount(Mage_Sales_Model_Quote_Address $address, $item)
{
$address->setTotalAmount('subtotal', $address->getTotalAmount('subtotal') + $item->getRowTotal());
$address->setBaseTotalAmount('subtotal', $address->getBaseTotalAmount('subtotal') + $item->getBaseRowTotal());
$address->setSubtotalInclTax($address->getSubtotalInclTax() + $item->getRowTotalInclTax());
$address->setBaseSubtotalInclTax($address->getBaseSubtotalInclTax() + $item->getBaseRowTotalInclTax());
return $this;
}