当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Sales_Model_Quote_Item_Abstract::hasCustomPrice方法代码示例

本文整理汇总了PHP中Mage_Sales_Model_Quote_Item_Abstract::hasCustomPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Item_Abstract::hasCustomPrice方法的具体用法?PHP Mage_Sales_Model_Quote_Item_Abstract::hasCustomPrice怎么用?PHP Mage_Sales_Model_Quote_Item_Abstract::hasCustomPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Sales_Model_Quote_Item_Abstract的用法示例。


在下文中一共展示了Mage_Sales_Model_Quote_Item_Abstract::hasCustomPrice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _aggregateTaxPerRate

 /**
  * Aggregate row totals per tax rate in array
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @param   float $rate
  * @param   array $taxGroups
  * @return  Mage_Tax_Model_Sales_Total_Quote
  */
 protected function _aggregateTaxPerRate($item, $rate, &$taxGroups)
 {
     $store = $item->getStore();
     $inclTax = $this->_usePriceIncludeTax($store);
     if ($inclTax) {
         $subtotal = $item->getTaxCalcRowTotal();
         $baseSubtotal = $item->getBaseTaxCalcRowTotal();
     } else {
         if ($item->hasCustomPrice() && $this->_helper->applyTaxOnCustomPrice($store)) {
             $subtotal = $item->getRowTotal();
             $baseSubtotal = $item->getBaseRowTotal();
         } else {
             $subtotal = $item->getTotalQty() * $item->getOriginalPrice();
             $baseSubtotal = $item->getTotalQty() * $item->getBaseOriginalPrice();
         }
     }
     $discountAmount = $item->getDiscountAmount();
     $baseDiscountAmount = $item->getBaseDiscountAmount();
     $qty = $item->getTotalQty();
     $rateKey = (string) $rate;
     /**
      * Add extra amounts which can be taxable too
      */
     $calcTotal = $subtotal + $item->getExtraRowTaxableAmount();
     $baseCalcTotal = $baseSubtotal + $item->getBaseExtraRowTaxableAmount();
     $item->setTaxPercent($rate);
     if (!isset($taxGroups[$rateKey]['totals'])) {
         $taxGroups[$rateKey]['totals'] = array();
     }
     if (!isset($taxGroups[$rateKey]['totals'])) {
         $taxGroups[$rateKey]['base_totals'] = array();
     }
     $calculationSequence = $this->_helper->getCalculationSequence($store);
     switch ($calculationSequence) {
         case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_EXCL:
             $rowTax = $this->_calculator->calcTaxAmount($calcTotal, $rate, $inclTax, false);
             $baseRowTax = $this->_calculator->calcTaxAmount($baseCalcTotal, $rate, $inclTax, false);
             break;
         case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_INCL:
             $rowTax = $this->_calculator->calcTaxAmount($calcTotal, $rate, $inclTax, false);
             $baseRowTax = $this->_calculator->calcTaxAmount($baseCalcTotal, $rate, $inclTax, false);
             $discountPrice = $inclTax ? $subtotal / $qty : ($subtotal + $rowTax) / $qty;
             $baseDiscountPrice = $inclTax ? $baseSubtotal / $qty : ($baseSubtotal + $baseRowTax) / $qty;
             $item->setDiscountCalculationPrice($discountPrice);
             $item->setBaseDiscountCalculationPrice($baseDiscountPrice);
             break;
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL:
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL:
             $calcTotal = $calcTotal - $discountAmount;
             $baseCalcTotal = $baseCalcTotal - $baseDiscountAmount;
             $rowTax = $this->_calculator->calcTaxAmount($calcTotal, $rate, $inclTax, false);
             $baseRowTax = $this->_calculator->calcTaxAmount($baseCalcTotal, $rate, $inclTax, false);
             break;
     }
     /**
      * "Delta" rounding
      */
     $delta = isset($this->_roundingDeltas[$rateKey]) ? $this->_roundingDeltas[$rateKey] : 0;
     $baseDelta = isset($this->_baseRoundingDeltas[$rateKey]) ? $this->_baseRoundingDeltas[$rateKey] : 0;
     $rowTax += $delta;
     $baseRowTax += $baseDelta;
     $this->_roundingDeltas[$rateKey] = $rowTax - $this->_calculator->round($rowTax);
     $this->_baseRoundingDeltas[$rateKey] = $baseRowTax - $this->_calculator->round($baseRowTax);
     $rowTax = $this->_calculator->round($rowTax);
     $baseRowTax = $this->_calculator->round($baseRowTax);
     /**
      * Renew item amounts in case if we are working with price include tax
      */
     if ($inclTax) {
         $unitTax = $this->_calculator->round($rowTax / $qty);
         $baseUnitTax = $this->_calculator->round($baseRowTax / $qty);
         if ($item->hasCustomPrice()) {
             $item->setCustomPrice($item->getPriceInclTax() - $unitTax);
             $item->setBaseCustomPrice($item->getBasePriceInclTax() - $baseUnitTax);
         } else {
             $item->setOriginalPrice($item->getPriceInclTax() - $unitTax);
             $item->setPrice($item->getBasePriceInclTax() - $baseUnitTax);
             $item->setBasePrice($item->getBasePriceInclTax() - $baseUnitTax);
         }
         $item->setRowTotal($item->getRowTotalInclTax() - $rowTax);
         $item->setBaseRowTotal($item->getBaseRowTotalInclTax() - $baseRowTax);
     }
     $item->setTaxAmount($rowTax);
     $item->setBaseTaxAmount($baseRowTax);
     $taxGroups[$rateKey]['totals'][] = $calcTotal;
     $taxGroups[$rateKey]['base_totals'][] = $baseCalcTotal;
     return $this;
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:96,代码来源:Tax.php

示例2: _recollectItem

 /**
  * Recollect item price and row total using after taxes subtract.
  * Declare item price including tax attributes
  *
  * @deprecated after 1.4.1
  *
  * @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 _recollectItem($address, Mage_Sales_Model_Quote_Item_Abstract $item)
 {
     $store = $address->getQuote()->getStore();
     $request = $this->_getStoreTaxRequest($address);
     $request->setProductClassId($item->getProduct()->getTaxClassId());
     $rate = $this->_calculator->getRate($request);
     $qty = $item->getTotalQty();
     $price = $taxPrice = $item->getCalculationPriceOriginal();
     $basePrice = $baseTaxPrice = $item->getBaseCalculationPriceOriginal();
     $subtotal = $taxSubtotal = $item->getRowTotal();
     $baseSubtotal = $baseTaxSubtotal = $item->getBaseRowTotal();
     if ($this->_config->discountTax($store)) {
         $item->setDiscountCalculationPrice($price);
         $item->setBaseDiscountCalculationPrice($basePrice);
     }
     /**
      * Use original price for tax calculation
      */
     if ($item->hasCustomPrice() && !$this->_helper->applyTaxOnCustomPrice($store)) {
         $taxPrice = $item->getOriginalPrice();
         $baseTaxPrice = $item->getBaseOriginalPrice();
         $taxSubtotal = $taxPrice * $qty;
         $baseTaxSubtotal = $baseTaxPrice * $qty;
     }
     if ($this->_areTaxRequestsSimilar) {
         $item->setRowTotalInclTax($subtotal);
         $item->setBaseRowTotalInclTax($baseSubtotal);
         $item->setPriceInclTax($price);
         $item->setBasePriceInclTax($basePrice);
         $item->setTaxCalcPrice($taxPrice);
         $item->setBaseTaxCalcPrice($baseTaxPrice);
         $item->setTaxCalcRowTotal($taxSubtotal);
         $item->setBaseTaxCalcRowTotal($baseTaxSubtotal);
     }
     $this->_subtotalInclTax += $subtotal;
     $this->_baseSubtotalInclTax += $baseSubtotal;
     if ($this->_config->getAlgorithm($store) == Mage_Tax_Model_Calculation::CALC_UNIT_BASE) {
         $taxAmount = $this->_calculator->calcTaxAmount($taxPrice, $rate, true);
         $baseTaxAmount = $this->_calculator->calcTaxAmount($baseTaxPrice, $rate, true);
         $unitPrice = $this->_calculator->round($price - $taxAmount);
         $baseUnitPrice = $this->_calculator->round($basePrice - $baseTaxAmount);
         $subtotal = $this->_calculator->round($unitPrice * $qty);
         $baseSubtotal = $this->_calculator->round($baseUnitPrice * $qty);
     } else {
         $taxAmount = $this->_calculator->calcTaxAmount($taxSubtotal, $rate, true, false);
         $baseTaxAmount = $this->_calculator->calcTaxAmount($baseTaxSubtotal, $rate, true, false);
         $unitPrice = ($subtotal - $taxAmount) / $qty;
         $baseUnitPrice = ($baseSubtotal - $baseTaxAmount) / $qty;
         $subtotal = $this->_calculator->round($subtotal - $taxAmount);
         $baseSubtotal = $this->_calculator->round($baseSubtotal - $baseTaxAmount);
     }
     if ($item->hasCustomPrice()) {
         $item->setCustomPrice($unitPrice);
         $item->setBaseCustomPrice($baseUnitPrice);
     }
     $item->setPrice($baseUnitPrice);
     $item->setOriginalPrice($unitPrice);
     $item->setBasePrice($baseUnitPrice);
     $item->setRowTotal($subtotal);
     $item->setBaseRowTotal($baseSubtotal);
     return $this;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:73,代码来源:Subtotal.php

示例3: _totalBaseCalculation

 /**
  * Calculate item price and row total including/excluding tax based on total price rounding level
  *
  * @param Mage_Sales_Model_Quote_Item_Abstract $item
  * @param Varien_Object $request
  * @return Mage_Tax_Model_Sales_Total_Quote_Subtotal
  */
 protected function _totalBaseCalculation($item, $request)
 {
     $calc = $this->_calculator;
     $request->setProductClassId($item->getProduct()->getTaxClassId());
     $rate = $calc->getRate($request);
     $qty = $item->getTotalQty();
     $price = $taxPrice = $item->getCalculationPriceOriginal();
     $basePrice = $baseTaxPrice = $item->getBaseCalculationPriceOriginal();
     $subtotal = $taxSubtotal = $item->getRowTotal();
     $baseSubtotal = $baseTaxSubtotal = $item->getBaseRowTotal();
     $taxOnOrigPrice = !$this->_helper->applyTaxOnCustomPrice($this->_store) && $item->hasCustomPrice();
     if ($taxOnOrigPrice) {
         $origSubtotal = $item->getOriginalPrice() * $qty;
         $baseOrigSubtotal = $item->getBaseOriginalPrice() * $qty;
     }
     $item->setTaxPercent($rate);
     if ($this->_config->priceIncludesTax($this->_store)) {
         if ($this->_sameRateAsStore($request)) {
             if ($taxOnOrigPrice) {
                 $rowTax = $this->_deltaRound($calc->calcTaxAmount($origSubtotal, $rate, true, false), $rate, true);
                 $baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseOrigSubtotal, $rate, true, false), $rate, true, 'base');
                 $taxable = $origSubtotal;
                 $baseTaxable = $baseOrigSubtotal;
             } else {
                 $rowTax = $this->_deltaRound($calc->calcTaxAmount($subtotal, $rate, true, false), $rate, true);
                 $baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseSubtotal, $rate, true, false), $rate, true, 'base');
                 $taxable = $subtotal;
                 $baseTaxable = $baseSubtotal;
             }
             $taxPrice = $price;
             $baseTaxPrice = $basePrice;
             $taxSubtotal = $subtotal;
             $baseTaxSubtotal = $baseSubtotal;
             $subtotal = $subtotal - $rowTax;
             $baseSubtotal = $baseSubtotal - $baseRowTax;
             $price = $calc->round($subtotal / $qty);
             $basePrice = $calc->round($baseSubtotal / $qty);
             $isPriceInclTax = true;
         } else {
             $storeRate = $calc->getStoreRate($request, $this->_store);
             if ($taxOnOrigPrice) {
                 $storeTax = $calc->calcTaxAmount($origSubtotal, $storeRate, true, false);
                 $baseStoreTax = $calc->calcTaxAmount($baseOrigSubtotal, $storeRate, true, false);
             } else {
                 $storeTax = $calc->calcTaxAmount($subtotal, $storeRate, true, false);
                 $baseStoreTax = $calc->calcTaxAmount($baseSubtotal, $storeRate, true, false);
             }
             $subtotal = $calc->round($subtotal - $storeTax);
             $baseSubtotal = $calc->round($baseSubtotal - $baseStoreTax);
             $price = $calc->round($subtotal / $qty);
             $basePrice = $calc->round($baseSubtotal / $qty);
             $rowTax = $this->_deltaRound($calc->calcTaxAmount($subtotal, $rate, false, false), $rate, true);
             $baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseSubtotal, $rate, false, false), $rate, true, 'base');
             $taxSubtotal = $subtotal + $rowTax;
             $baseTaxSubtotal = $baseSubtotal + $baseRowTax;
             $taxPrice = $calc->round($taxSubtotal / $qty);
             $baseTaxPrice = $calc->round($baseTaxSubtotal / $qty);
             $taxable = $subtotal;
             $baseTaxable = $baseSubtotal;
             $isPriceInclTax = false;
         }
     } else {
         if ($taxOnOrigPrice) {
             $rowTax = $this->_deltaRound($calc->calcTaxAmount($origSubtotal, $rate, false, false), $rate, true);
             $baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseOrigSubtotal, $rate, false, false), $rate, true, 'base');
             $taxable = $origSubtotal;
             $baseTaxable = $baseOrigSubtotal;
         } else {
             $rowTax = $this->_deltaRound($calc->calcTaxAmount($subtotal, $rate, false, false), $rate, true);
             $baseRowTax = $this->_deltaRound($calc->calcTaxAmount($baseSubtotal, $rate, false, false), $rate, true, 'base');
             $taxable = $subtotal;
             $baseTaxable = $baseSubtotal;
         }
         $taxSubtotal = $subtotal + $rowTax;
         $baseTaxSubtotal = $baseSubtotal + $baseRowTax;
         $taxPrice = $calc->round($taxSubtotal / $qty);
         $baseTaxPrice = $calc->round($baseTaxSubtotal / $qty);
         $isPriceInclTax = false;
     }
     if ($item->hasCustomPrice()) {
         /**
          * Initialize item original price before declaring custom price
          */
         $item->getOriginalPrice();
         $item->setCustomPrice($price);
         $item->setBaseCustomPrice($basePrice);
     } else {
         $item->setConvertedPrice($price);
     }
     $item->setPrice($basePrice);
     $item->setBasePrice($basePrice);
     $item->setRowTotal($subtotal);
     $item->setBaseRowTotal($baseSubtotal);
//.........这里部分代码省略.........
开发者ID:natxetee,项目名称:magento2,代码行数:101,代码来源:Subtotal.php


注:本文中的Mage_Sales_Model_Quote_Item_Abstract::hasCustomPrice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。