本文整理汇总了PHP中Mage_Sales_Model_Quote_Address::getAppliedTaxes方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Address::getAppliedTaxes方法的具体用法?PHP Mage_Sales_Model_Quote_Address::getAppliedTaxes怎么用?PHP Mage_Sales_Model_Quote_Address::getAppliedTaxes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Address
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Address::getAppliedTaxes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _saveAppliedTaxes
protected function _saveAppliedTaxes(Mage_Sales_Model_Quote_Address $address, $applied, $amount, $baseAmount, $rate)
{
$previouslyAppliedTaxes = $address->getAppliedTaxes();
$process = count($previouslyAppliedTaxes);
foreach ($applied as $row) {
if (!isset($previouslyAppliedTaxes[$row['id']])) {
$row['process'] = $process;
$row['amount'] = 0;
$row['base_amount'] = 0;
$previouslyAppliedTaxes[$row['id']] = $row;
}
if (!is_null($row['percent'])) {
$row['percent'] = $row['percent'] ? $row['percent'] : 1;
$rate = $rate ? $rate : 1;
$appliedAmount = $amount;
$baseAppliedAmount = $baseAmount;
} else {
$appliedAmount = 0;
$baseAppliedAmount = 0;
foreach ($row['rates'] as $rate) {
$appliedAmount += $rate['amount'];
$baseAppliedAmount += $rate['base_amount'];
}
}
if ($appliedAmount || $previouslyAppliedTaxes[$row['id']]['amount']) {
$previouslyAppliedTaxes[$row['id']]['amount'] = $appliedAmount;
$previouslyAppliedTaxes[$row['id']]['base_amount'] = $baseAppliedAmount;
} else {
unset($previouslyAppliedTaxes[$row['id']]);
}
}
$address->setAppliedTaxes($previouslyAppliedTaxes);
}
示例2: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$address->setPaymentCharge(0);
$address->setBasePaymentCharge(0);
$storeId = Mage::app()->getStore()->getId();
$items = $address->getAllItems();
if (!count($items)) {
return $this;
}
$paymentMethod = $address->getQuote()->getPayment()->getMethod();
$quote = $address->getQuote();
if ($paymentMethod && substr($paymentMethod, 0, 11) == 'pay_payment') {
$baseAmount = Mage::helper('pay_payment')->getPaymentCharge($paymentMethod, $address->getQuote());
$amount = Mage::helper('directory')->currencyConvert($baseAmount, Mage::app()->getWebsite()->getConfig('currency/options/default'), Mage::app()->getStore()->getCurrentCurrencyCode());
$address->setPaymentCharge($amount);
$address->setBasePaymentCharge($baseAmount);
$taxClass = Mage::helper('pay_payment')->getPaymentChargeTaxClass($paymentMethod);
$taxCalculationModel = Mage::getSingleton('tax/calculation');
$request = $taxCalculationModel->getRateRequest($quote->getShippingAddress(), $quote->getBillingAddress(), null, $storeId);
$request->setStore(Mage::app()->getStore());
$rate = $taxCalculationModel->getRate($request->setProductClassId($taxClass));
//$rate = 21;
if ($rate > 0) {
// $includesTax = Mage::getStoreConfig('tax/calculation/price_includes_tax');
$baseChargeTax = round($address->getBasePaymentCharge() / (1 + $rate / 100) * ($rate / 100), 2);
$chargeTax = round($address->getPaymentCharge() / (1 + $rate / 100) * ($rate / 100), 2);
} else {
$baseChargeTax = 0;
$chargeTax = 0;
}
$rates = array();
$applied = false;
foreach ($address->getAppliedTaxes() as $arrRate) {
// maximaal 1 keer de btw voor de extra kosten toevoegen
if ($arrRate['percent'] == $rate && !$applied) {
$applied = true;
$arrRate['amount'] = $arrRate['amount'] + $chargeTax;
$arrRate['base_amount'] = $arrRate['base_amount'] + $baseChargeTax;
}
$rates[] = $arrRate;
}
$address->setAppliedTaxes($rates);
$address->setBaseTaxAmount($address->getBaseTaxAmount() + $baseChargeTax);
$address->setTaxAmount($address->getTaxAmount() + $chargeTax);
$address->setGrandTotal($address->getGrandTotal() + $address->getPaymentCharge());
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBasePaymentCharge());
}
return $this;
}
示例3: fetch
/**
* Add tax totals information to address object
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Tax_Model_Sales_Total_Quote
*/
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$applied = $address->getAppliedTaxes();
$store = $address->getQuote()->getStore();
$amount = $address->getTaxAmount();
$area = null;
if ($this->_config->displayCartTaxWithGrandTotal($store) && $address->getGrandTotal()) {
$area = 'taxes';
}
if ($amount != 0 || $this->_config->displayCartZeroTax($store)) {
$address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('tax')->__('Tax'), 'full_info' => $applied ? $applied : array(), 'value' => $amount, 'area' => $area));
}
$store = $address->getQuote()->getStore();
/**
* Modify subtotal
*/
if ($this->_config->displayCartSubtotalBoth($store) || $this->_config->displayCartSubtotalInclTax($store)) {
if ($address->getSubtotalInclTax() > 0) {
$subtotalInclTax = $address->getSubtotalInclTax();
} else {
$subtotalInclTax = $address->getSubtotal() + $address->getTaxAmount() - $address->getShippingTaxAmount();
}
$address->addTotal(array('code' => 'subtotal', 'title' => Mage::helper('sales')->__('Subtotal'), 'value' => $subtotalInclTax, 'value_incl_tax' => $subtotalInclTax, 'value_excl_tax' => $address->getSubtotal()));
}
return $this;
}
示例4: fetch
/**
* Add tax totals information to address object
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Tax_Model_Sales_Total_Quote
*/
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$applied = $address->getAppliedTaxes();
$store = $address->getQuote()->getStore();
$amount = $address->getTaxAmount();
$items = $this->_getAddressItems($address);
$discountTaxCompensation = 0;
foreach ($items as $item) {
$discountTaxCompensation += $item->getDiscountTaxCompensation();
}
$taxAmount = $amount + $discountTaxCompensation;
/*
* when weee discount is not included in extraTaxAmount, we need to add it to the total tax
*/
if ($this->_weeeHelper->isEnabled()) {
if (!$this->_weeeHelper->includeInSubtotal()) {
$taxAmount += $address->getWeeeDiscount();
}
}
$area = null;
if ($this->_config->displayCartTaxWithGrandTotal($store) && $address->getGrandTotal()) {
$area = 'taxes';
}
if ($amount != 0 || $this->_config->displayCartZeroTax($store)) {
$address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('tax')->__('Tax'), 'full_info' => $applied ? $applied : array(), 'value' => $amount, 'area' => $area));
}
$store = $address->getQuote()->getStore();
/**
* Modify subtotal
*/
if ($this->_config->displayCartSubtotalBoth($store) || $this->_config->displayCartSubtotalInclTax($store)) {
if ($address->getSubtotalInclTax() > 0) {
$subtotalInclTax = $address->getSubtotalInclTax();
} else {
$subtotalInclTax = $address->getSubtotal() + $taxAmount - $address->getShippingTaxAmount();
}
$address->addTotal(array('code' => 'subtotal', 'title' => Mage::helper('sales')->__('Subtotal'), 'value' => $subtotalInclTax, 'value_incl_tax' => $subtotalInclTax, 'value_excl_tax' => $address->getSubtotal()));
}
return $this;
}
示例5: fetch
/**
* Add tax totals information to address object
*
* @param Mage_Sales_Model_Quote_Address $address
* @return $this
*/
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$config = Mage::getSingleton('tax/config');
$quote = $address->getQuote();
$store = $quote->getStore();
$amount = $address->getTaxAmount();
if ($amount != 0 || Mage::helper('tax')->displayZeroTax($store)) {
$address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('tax')->__('Tax'), 'full_info' => $address->getAppliedTaxes(), 'value' => $amount, 'area' => null));
}
/**
* Modify subtotal
*/
if (method_exists($config, "displayCartSubtotalBoth") && method_exists($config, "displayCartSubtotalInclTax") && ($config->displayCartSubtotalBoth($store) || $config->displayCartSubtotalInclTax($store))) {
if ($address->getSubtotalInclTax() > 0) {
$subtotalInclTax = $address->getSubtotalInclTax();
} else {
$subtotalInclTax = $address->getSubtotal() + $address->getTaxAmount() - $address->getShippingTaxAmount();
}
$address->addTotal(array('code' => 'subtotal', 'title' => Mage::helper('sales')->__('Subtotal'), 'value' => $subtotalInclTax, 'value_incl_tax' => $subtotalInclTax, 'value_excl_tax' => $address->getSubtotal()));
}
return $this;
}