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


PHP Mage_Sales_Model_Quote_Item_Abstract::getBaseRowTotal方法代码示例

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


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

示例1: requestShippingRates

 /**
  * Request shipping rates for entire address or specified address item
  * Returns true if current selected shipping method code corresponds to one of the found rates
  *
  * @param Mage_Sales_Model_Quote_Item_Abstract $item
  * @return bool
  */
 public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null)
 {
     //Mage::log("requestShippingRates");
     /** @var $request Mage_Shipping_Model_Rate_Request */
     $request = Mage::getModel('shipping/rate_request');
     $request->setAllItems($item ? array($item) : $this->getAllItems());
     $request->setDestCountryId($this->getCountryId());
     $request->setDestRegionId($this->getRegionId());
     $request->setDestRegionCode($this->getRegionCode());
     /**
      * need to call getStreet with -1
      * to get data in string instead of array
      */
     $request->setDestStreet($this->getStreet(-1));
     $request->setDestCity($this->getCity());
     $request->setDestPostcode($this->getPostcode());
     $request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());
     $packageValueWithDiscount = $item ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() : $this->getBaseSubtotalWithDiscount();
     $request->setPackageValueWithDiscount($packageValueWithDiscount);
     $request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());
     $request->setPackageQty($item ? $item->getQty() : $this->getItemQty());
     /**
      * Need for shipping methods that use insurance based on price of physical products
      */
     $packagePhysicalValue = $item ? $item->getBaseRowTotal() : $this->getBaseSubtotal() - $this->getBaseVirtualAmount();
     $request->setPackagePhysicalValue($packagePhysicalValue);
     $request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight());
     /**
      * Store and website identifiers need specify from quote
      */
     /*$request->setStoreId(Mage::app()->getStore()->getId());
       $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/
     $request->setStoreId($this->getQuote()->getStore()->getId());
     $request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId());
     $request->setFreeShipping($this->getFreeShipping());
     /**
      * Currencies need to convert in free shipping
      */
     $request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency());
     $request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency());
     $request->setLimitCarrier($this->getLimitCarrier());
     $result = Mage::getModel('shipping/shipping')->collectRatesWithAddress($request, $this)->getResult();
     $found = false;
     if ($result) {
         $shippingRates = $result->getAllRates();
         foreach ($shippingRates as $shippingRate) {
             $rate = Mage::getModel('sales/quote_address_rate')->importShippingRate($shippingRate);
             if (!$item) {
                 $this->addShippingRate($rate);
             }
             if ($this->getShippingMethod() == $rate->getCode()) {
                 if ($item) {
                     $item->setBaseShippingAmount($rate->getPrice());
                 } else {
                     /**
                      * possible bug: this should be setBaseShippingAmount(),
                      * see Mage_Sales_Model_Quote_Address_Total_Shipping::collect()
                      * where this value is set again from the current specified rate price
                      * (looks like a workaround for this bug)
                      */
                     $this->setShippingAmount($rate->getPrice());
                 }
                 $found = true;
             }
         }
     }
     return $found;
 }
开发者ID:Hospeed,项目名称:Inovarti_PromoFilter,代码行数:75,代码来源:Address.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: resetItem

 protected function resetItem(Mage_Sales_Model_Quote_Item_Abstract $item)
 {
     $item->setDiscountAmount(0.0);
     $item->setBaseDiscountAmount(0.0);
     $item->setRowTotalWithDiscount($item->getRowTotal());
     $item->setBaseRowTotalWithDiscount($item->getBaseRowTotal());
     $item->setDiscountPercent(0);
     $item->setAppliedRuleIds('');
     $item->setFreeShipping(false);
 }
开发者ID:aoepeople,项目名称:aoe_salesrule,代码行数:10,代码来源:Discount.php

示例4: apply

 public function apply(Mage_Sales_Model_Quote_Item_Abstract $item)
 {
     # Do not apply any discount if Ext is Disabled
     if (Mage::helper('referafriend')->getExtDisabled()) {
         return $this;
     }
     $this->_quote = $quote = $item->getQuote();
     if ($item instanceof Mage_Sales_Model_Quote_Address_Item) {
         $address = $item->getAddress();
     } elseif ($quote->isVirtual()) {
         $address = $quote->getBillingAddress();
     } else {
         $address = $quote->getShippingAddress();
     }
     # allow additional discount logic start
     $hasAdditional = $item->getQuote()->getCouponCode() ? true : false;
     $helper = Mage::helper('referafriend/referrer');
     $baseSubtotal = $address->getBaseSubtotal();
     $clearUse = array();
     if (!$this->_discount) {
         Mage::helper('referafriend')->setCustomerDiscount(0);
         $customer = $quote->getCustomer();
         $referrerId = $customer->getId();
         $discounts = Mage::getResourceModel('referafriend/discount_collection')->loadByReferrer($referrerId);
         if (count($discounts)) {
             foreach ($discounts as $discount) {
                 $rule = Mage::getSingleton('referafriend/rule')->load($discount->getRuleId());
                 if ($rule->getDiscountUsage() == 0 || $rule->getDiscountUsage() > $discount->getDiscountUsed()) {
                     # allow additional discount logic
                     if ($hasAdditional && $rule->getAllowAdditionalDiscount() || !$hasAdditional) {
                         $this->_discount[$discount->getId()] = $discount;
                     } else {
                         $clearUse[] = $discount->getId();
                     }
                 }
             }
         }
     }
     if (!count($this->_discount)) {
         # Reset used discount
         $customer = Mage::getSingleton('customer/session');
         if ($customer->isLoggedIn()) {
             $customer->setDiscountUsed(array());
         }
         return $this;
     }
     $this->_getCouponCode();
     //        $this->_couponCode = $this->_getCouponCode();
     $customer = Mage::getSingleton('customer/session');
     if ($customer->isLoggedIn()) {
         $discountUsed = (array) $customer->getDiscountUsed();
     }
     $rafDiscount = Mage::helper('referafriend')->getCustomerDiscount(false) ? Mage::helper('referafriend')->getCustomerDiscount(false) : 0;
     $notUsed = array();
     foreach ($this->_discount as $discountId => $discount) {
         $discountAmount = 0;
         $baseDiscountAmount = 0;
         $rule = Mage::getModel('referafriend/rule')->load($discount->getRuleId());
         switch ($discount->getType()) {
             case self::TYPE_PERCENT:
                 $discountPercent = min(100, $discount->getAmount());
                 $discountAmount = ($item->getRowTotal() - $item->getDiscountAmount()) * $discountPercent / 100;
                 $baseDiscountAmount = ($item->getBaseRowTotal() - $item->getBaseDiscountAmount()) * $discountPercent / 100;
                 $checkDiscountAmount = $baseSubtotal * $discountPercent / 100;
                 if (!($rule->getDiscountGreater() && $checkDiscountAmount < $rule->getDiscountGreater()) && !($rule->getTotalGreater() && $baseSubtotal < $rule->getTotalGreater())) {
                     if (isset($discountUsed)) {
                         if (!isset($discountUsed[$discountId])) {
                             $discountUsed[$discountId] = false;
                         }
                     }
                     $rafDiscount += $baseDiscountAmount;
                     $discountAmount = min($discountAmount + $item->getDiscountAmount(), $item->getRowTotal());
                     $baseDiscountAmount = min($baseDiscountAmount + $item->getBaseDiscountAmount(), $item->getBaseRowTotal());
                     //$discountPercent = min(100, $item->getDiscountPercent()+$percentDiscount);
                     $item->setDiscountPercent(min(100, $item->getDiscountPercent() + $discountPercent));
                     $discountAmount = $quote->getStore()->roundPrice($discountAmount);
                     $baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount);
                     $item->setDiscountAmount($discountAmount);
                     $item->setBaseDiscountAmount($baseDiscountAmount);
                 } else {
                     $notUsed[] = $discountId;
                     if (isset($discountUsed[$discountId])) {
                         unset($discountUsed[$discountId]);
                     }
                 }
                 break;
             case self::TYPE_FLATRATE:
                 $discountAmount = min($item->getRowTotal() - $item->getDiscountAmount(), $quote->getStore()->convertPrice($discount->getAmount()));
                 $baseDiscountAmount = min($item->getBaseRowTotal() - $item->getBaseDiscountAmount(), $discount->getAmount());
                 $checkDiscountAmount = $discount->getAmount();
                 if (!($rule->getDiscountGreater() && $checkDiscountAmount < $rule->getDiscountGreater()) && !($rule->getTotalGreater() && $baseSubtotal < $rule->getTotalGreater())) {
                     if (isset($discountUsed)) {
                         if (!isset($discountUsed[$discountId])) {
                             $discountUsed[$discountId] = false;
                         }
                     }
                     $rafDiscount += $baseDiscountAmount;
                     $this->_discount[$discountId]->setAmount($discount->getAmount() - $baseDiscountAmount);
                     /*$discountAmount     = $quote->getStore()->roundPrice($discountAmount);
                       $baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount);*/
//.........这里部分代码省略.........
开发者ID:bevello,项目名称:bevello,代码行数:101,代码来源:Discount.php

示例5: _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)
 {
     $inclTax = $item->getIsPriceInclTax();
     $rateKey = (string) $rate;
     $subtotal = $item->getTaxableAmount() + $item->getExtraRowTaxableAmount();
     $baseSubtotal = $item->getBaseTaxableAmount() + $item->getBaseExtraRowTaxableAmount();
     $item->setTaxPercent($rate);
     if (!isset($taxGroups[$rateKey]['totals'])) {
         $taxGroups[$rateKey]['totals'] = array();
         $taxGroups[$rateKey]['base_totals'] = array();
     }
     $hiddenTax = null;
     $baseHiddenTax = null;
     switch ($this->_helper->getCalculationSequence($this->_store)) {
         case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_EXCL:
         case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_INCL:
             $rowTax = $this->_calculator->calcTaxAmount($subtotal, $rate, $inclTax, false);
             $baseRowTax = $this->_calculator->calcTaxAmount($baseSubtotal, $rate, $inclTax, false);
             break;
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL:
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL:
             $discount = $item->getDiscountAmount();
             $baseDiscount = $item->getBaseDiscountAmount();
             $subtotal -= $discount;
             $baseSubtotal -= $baseDiscount;
             $rowTax = $this->_calculator->calcTaxAmount($subtotal, $rate, $inclTax, false);
             $baseRowTax = $this->_calculator->calcTaxAmount($baseSubtotal, $rate, $inclTax, false);
             break;
     }
     $rowTax = $this->_deltaRound($rowTax, $rateKey, $inclTax);
     $baseRowTax = $this->_deltaRound($baseRowTax, $rateKey, $inclTax, 'base');
     if ($inclTax && !empty($discount)) {
         $hiddenTax = $item->getRowTotalInclTax() - $item->getRowTotal() - $rowTax;
         $baseHiddenTax = $item->getBaseRowTotalInclTax() - $item->getBaseRowTotal() - $baseRowTax;
     }
     $item->setTaxAmount(max(0, $rowTax));
     $item->setBaseTaxAmount(max(0, $baseRowTax));
     $item->setHiddenTaxAmount(max(0, $hiddenTax));
     $item->setBaseHiddenTaxAmount(max(0, $baseHiddenTax));
     $taxGroups[$rateKey]['totals'][] = max(0, $subtotal);
     $taxGroups[$rateKey]['base_totals'][] = max(0, $baseSubtotal);
     return $this;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:51,代码来源:Tax.php

示例6: _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

示例7: requestShippingRates

 /**
  * Request shipping rates for entire address or specified address item
  * Returns true if current selected shipping method code corresponds to one of the found rates
  *
  * @param Mage_Sales_Model_Quote_Item_Abstract $item
  * @return bool
  */
 public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null)
 {
     /** @var $request Mage_Shipping_Model_Rate_Request */
     $request = Mage::getModel('shipping/rate_request');
     $request->setAllItems($item ? array($item) : $this->getAllItems());
     $request->setDestCountryId($this->getCountryId());
     $request->setDestRegionId($this->getRegionId());
     $request->setDestRegionCode($this->getRegionCode());
     /**
      * need to call getStreet with -1
      * to get data in string instead of array
      */
     $request->setDestStreet($this->getStreet(-1));
     $request->setDestCity($this->getCity());
     $request->setDestPostcode($this->getPostcode());
     $request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());
     $packageValueWithDiscount = $item ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() : $this->getBaseSubtotalWithDiscount();
     $request->setPackageValueWithDiscount($packageValueWithDiscount);
     $request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());
     $request->setPackageQty($item ? $item->getQty() : $this->getItemQty());
     /**
      * Need for shipping methods that use insurance based on price of physical products
      */
     $packagePhysicalValue = $item ? $item->getBaseRowTotal() : $this->getBaseSubtotal() - $this->getBaseVirtualAmount();
     $request->setPackagePhysicalValue($packagePhysicalValue);
     $request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight());
     /**
      * Store and website identifiers need specify from quote
      */
     /*$request->setStoreId(Mage::app()->getStore()->getId());
       $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/
     $request->setStoreId($this->getQuote()->getStore()->getId());
     $request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId());
     $request->setFreeShipping($this->getFreeShipping());
     /**
      * Currencies need to convert in free shipping
      */
     $request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency());
     $request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency());
     $request->setLimitCarrier($this->getLimitCarrier());
     $request->setBaseSubtotalInclTax($this->getBaseSubtotalInclTax());
     $result = Mage::getModel('shipping/shipping')->collectRates($request)->getResult();
     $found = false;
     if ($result) {
         $shippingRates = $result->getAllRates();
         // ============ Apply shipping on order minimum value after discount specific to coupon code only =================
         if (!Mage::app()->getStore()->isAdmin()) {
             foreach ($shippingRates as $i => $r) {
                 if ($r->getMethod() == 'freeshipping') {
                     unset($shippingRates[$i]);
                 }
             }
         }
         $isfree = true;
         $minimum_purchange_amount = Mage::getStoreConfig('sales/minimum_order_custom/minimum_purchange_amount');
         $minimum_purchange_amount_status = Mage::getStoreConfig('sales/minimum_order_custom/minimum_purchange_amount_status');
         if ($minimum_purchange_amount_status == '1' && $minimum_purchange_amount > 0) {
             $minPurchaseAmt = Mage::helper('common')->checkMinPurchageAmount($minimum_purchange_amount);
             if ($minPurchaseAmt) {
                 foreach ($shippingRates as $i => $r) {
                     if ($r->getMethod() == 'standard') {
                         $shippingRates[$i]->setPrice(0);
                         $shippingRates[$i]->setCost(0);
                         $isfree = true;
                     }
                 }
             }
         }
         // ==========================================================================================
         foreach ($shippingRates as $shippingRate) {
             $rate = Mage::getModel('sales/quote_address_rate')->importShippingRate($shippingRate);
             if (!$item) {
                 $this->addShippingRate($rate);
             }
             if ($this->getShippingMethod() == $rate->getCode()) {
                 if ($item) {
                     $item->setBaseShippingAmount($rate->getPrice());
                 } else {
                     /**
                      * possible bug: this should be setBaseShippingAmount(),
                      * see Mage_Sales_Model_Quote_Address_Total_Shipping::collect()
                      * where this value is set again from the current specified rate price
                      * (looks like a workaround for this bug)
                      */
                     $this->setShippingAmount($rate->getPrice());
                 }
                 $found = true;
             }
         }
     }
     return $found;
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:99,代码来源:Address.php

示例8: requestShippingRates

 /**
  * WE NEEDED TO OVERRIDE THIS METHOD CALL TO UPDATE THE SHIPPING RATES AS
  * SOON AS WE RECEIVED THEM
  * 
  * 
  * 
  * 
  * Request shipping rates for entire address or specified address item
  * Returns true if current selected shipping method code corresponds to one of the found rates
  *
  * @param Mage_Sales_Model_Quote_Item_Abstract $item
  * @return bool
  */
 public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null)
 {
     /**
      * CUSTOMIZED THIS FUNCTION BY ADDING THIS EVENT CALL
      */
     if (!$this->getQuote()->getShippingAddress()->getResidentialIndicator()) {
         Mage::dispatchEvent('widgetized_validate_address', array($this->_eventObject => $this, 'order' => $this->getQuote()));
     }
     /** @var $request Mage_Shipping_Model_Rate_Request */
     $request = Mage::getModel('shipping/rate_request');
     $request->setQuote($this->getQuote());
     $request->setAllItems($item ? array($item) : $this->getAllItems());
     $request->setDestCountryId($this->getCountryId());
     $request->setDestRegionId($this->getRegionId());
     $request->setDestRegionCode($this->getRegionCode());
     /**
      * need to call getStreet with -1
      * to get data in string instead of array
      */
     $request->setDestStreet($this->getStreet(self::DEFAULT_DEST_STREET));
     $request->setDestCity($this->getCity());
     $request->setDestPostcode($this->getPostcode());
     $request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());
     $packageValueWithDiscount = $item ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() : $this->getBaseSubtotalWithDiscount();
     $request->setPackageValueWithDiscount($packageValueWithDiscount);
     $request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());
     $request->setPackageQty($item ? $item->getQty() : $this->getItemQty());
     /**
      * Need for shipping methods that use insurance based on price of physical products
      */
     $packagePhysicalValue = $item ? $item->getBaseRowTotal() : $this->getBaseSubtotal() - $this->getBaseVirtualAmount();
     $request->setPackagePhysicalValue($packagePhysicalValue);
     $request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight());
     /**
      * Store and website identifiers need specify from quote
      */
     /*$request->setStoreId(Mage::app()->getStore()->getId());
       $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/
     $request->setStoreId($this->getQuote()->getStore()->getId());
     $request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId());
     $request->setFreeShipping($this->getFreeShipping());
     /**
      * Currencies need to convert in free shipping
      */
     $request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency());
     $request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency());
     $request->setLimitCarrier($this->getLimitCarrier());
     $request->setBaseSubtotalInclTax($this->getBaseSubtotalInclTax() + $this->getBaseExtraTaxAmount());
     $result = Mage::getModel('shipping/shipping')->collectRates($request)->getResult();
     $found = false;
     if ($result) {
         $shippingRates = $result->getAllRates();
         //            var_dump($shippingRates);die;
         /**
          * CUSTOMIZED THIS FUNCTION BY ADDING THIS EVENT CALL
          */
         Mage::dispatchEvent($this->_eventPrefix . '_update_shipping_rates', array($this->_eventObject => $this, 'shipping_rates' => $shippingRates));
         foreach ($shippingRates as $shippingRate) {
             $rate = Mage::getModel('sales/quote_address_rate')->importShippingRate($shippingRate);
             /**
              * COST is Cheaper than the PRICE
              * 
              * We don't want to use the price, we want to give shipping
              * to users at cost.
              */
             if (!$item) {
                 $this->addShippingRate($rate);
             }
             if ($this->getShippingMethod() == $rate->getCode()) {
                 $price = $rate->getCost();
                 if (!$price) {
                     $price = $rate->getPrice();
                 }
                 if ($item) {
                     $item->setBaseShippingAmount($price);
                 } else {
                     /**
                      * possible bug: this should be setBaseShippingAmount(),
                      * see Mage_Sales_Model_Quote_Address_Total_Shipping::collect()
                      * where this value is set again from the current specified rate price
                      * (looks like a workaround for this bug)
                      */
                     $this->setShippingAmount($price);
                 }
                 $found = true;
             }
         }
//.........这里部分代码省略.........
开发者ID:Jonathonbyrd,项目名称:Optimized-Magento-1.9.x,代码行数:101,代码来源:Address.php

示例9: requestShippingRates

 /**
  * Request shipping rates for entire address or specified address item
  * Returns true if current selected shipping method code corresponds to one of the found rates
  *
  * @param Mage_Sales_Model_Quote_Item_Abstract $item
  * @return bool
  */
 public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null)
 {
     /** @var $request Mage_Shipping_Model_Rate_Request */
     $request = Mage::getModel('shipping/rate_request');
     $request->setAllItems($item ? array($item) : $this->getAllItems());
     $request->setDestCountryId($this->getCountryId());
     $request->setDestRegionId($this->getRegionId());
     $request->setDestRegionCode($this->getRegionCode());
     /**
      * need to call getStreet with -1
      * to get data in string instead of array
      */
     $request->setDestStreet($this->getStreet(-1));
     $request->setDestCity($this->getCity());
     $request->setDestPostcode($this->getPostcode());
     $request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());
     $packageValueWithDiscount = $item ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() : $this->getBaseSubtotalWithDiscount();
     $request->setPackageValueWithDiscount($packageValueWithDiscount);
     $request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());
     $request->setPackageQty($item ? $item->getQty() : $this->getItemQty());
     /**
      * Need for shipping methods that use insurance based on price of physical products
      */
     $packagePhysicalValue = $item ? $item->getBaseRowTotal() : $this->getBaseSubtotal() - $this->getBaseVirtualAmount();
     $request->setPackagePhysicalValue($packagePhysicalValue);
     $request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight());
     /**
      * Store and website identifiers need specify from quote
      */
     /*$request->setStoreId(Mage::app()->getStore()->getId());
       $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/
     $request->setStoreId($this->getQuote()->getStore()->getId());
     $request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId());
     $request->setFreeShipping($this->getFreeShipping());
     /**
      * Currencies need to convert in free shipping
      */
     $request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency());
     $request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency());
     $request->setLimitCarrier($this->getLimitCarrier());
     $request->setBaseSubtotalInclTax($this->getBaseSubtotalInclTax());
     $result = Mage::getModel('shipping/shipping')->collectRates($request)->getResult();
     $found = true;
     return $found;
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:52,代码来源:Address.php

示例10: _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;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:15,代码来源:Subtotal.php

示例11: itemToOrderItem

 /**
  * Convert quote item to order item
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @return  Mage_Sales_Model_Order_Item
  */
 public function itemToOrderItem(Mage_Sales_Model_Quote_Item_Abstract $item)
 {
     $orderItem = Mage::getModel('sales/order_item')->setStoreId($item->getStoreId())->setQuoteItemId($item->getId())->setProductId($item->getProductId())->setSuperProductId($item->getSuperProductId())->setParentProductId($item->getParentProductId())->setSku($item->getSku())->setName($item->getName())->setDescription($item->getDescription())->setWeight($item->getWeight())->setIsQtyDecimal($item->getIsQtyDecimal())->setQtyOrdered($item->getQty())->setOriginalPrice($item->getOriginalPrice())->setAppliedRuleIds($item->getAppliedRuleIds())->setAdditionalData($item->getAdditionalData())->setPrice($item->getCalculationPrice())->setTaxPercent($item->getTaxPercent())->setTaxAmount($item->getTaxAmount())->setRowWeight($item->getRowWeight())->setRowTotal($item->getRowTotal())->setBasePrice($item->getBaseCalculationPrice())->setBaseOriginalPrice($item->getPrice())->setBaseTaxAmount($item->getBaseTaxAmount())->setBaseRowTotal($item->getBaseRowTotal());
     if (!$item->getNoDiscount()) {
         $orderItem->setDiscountPercent($item->getDiscountPercent())->setDiscountAmount($item->getDiscountAmount())->setBaseDiscountAmount($item->getBaseDiscountAmount());
     }
     Mage::dispatchEvent('sales_convert_quote_item_to_order_item', array('order_item' => $orderItem, 'item' => $item));
     return $orderItem;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:15,代码来源:Quote.php

示例12: _calcRowTaxAmount

 /**
  * Calculate item tax amount based on row total
  *
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @param   float $rate
  * @return  Mage_Tax_Model_Sales_Total_Quote
  */
 protected function _calcRowTaxAmount($item, $rate)
 {
     $inclTax = $item->getIsPriceInclTax();
     $subtotal = $item->getTaxableAmount() + $item->getExtraRowTaxableAmount();
     $baseSubtotal = $item->getBaseTaxableAmount() + $item->getBaseExtraRowTaxableAmount();
     $item->setTaxPercent($rate);
     $hiddenTax = null;
     $baseHiddenTax = null;
     switch ($this->_helper->getCalculationSequence($this->_store)) {
         case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_EXCL:
         case Mage_Tax_Model_Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_INCL:
             $rowTax = $this->_calculator->calcTaxAmount($subtotal, $rate, $inclTax);
             $baseRowTax = $this->_calculator->calcTaxAmount($baseSubtotal, $rate, $inclTax);
             break;
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL:
         case Mage_Tax_Model_Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL:
             $discountAmount = $item->getDiscountAmount();
             $baseDiscountAmount = $item->getBaseDiscountAmount();
             $rowTax = $this->_calculator->calcTaxAmount(max($subtotal - $discountAmount, 0), $rate, $inclTax);
             $baseRowTax = $this->_calculator->calcTaxAmount(max($baseSubtotal - $baseDiscountAmount, 0), $rate, $inclTax);
             if ($inclTax && $discountAmount > 0) {
                 $hiddenTax = $subtotal - $rowTax - $item->getRowTotal();
                 $baseHiddenTax = $baseSubtotal - $baseRowTax - $item->getBaseRowTotal();
             } elseif ($discountAmount > $subtotal) {
                 // case with 100% discount on price incl. tax
                 $hiddenTax = $discountAmount - $subtotal;
                 $baseHiddenTax = $baseDiscountAmount - $baseSubtotal;
             }
             break;
     }
     $item->setTaxAmount(max(0, $rowTax));
     $item->setBaseTaxAmount(max(0, $baseRowTax));
     $item->setHiddenTaxAmount(max(0, $hiddenTax));
     $item->setBaseHiddenTaxAmount(max(0, $baseHiddenTax));
     return $this;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:43,代码来源:Tax.php


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