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


PHP Mage_Sales_Model_Quote_Item_Abstract::getDiscountPercent方法代码示例

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


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

示例1: _processItem

 /**
  * Process item fixed taxes
  *
  * @deprecated since 1.3.2.3
  * @param   Mage_Sales_Model_Quote_Address $address
  * @param   Mage_Sales_Model_Quote_Item_Abstract $item
  * @param   bool $updateParent
  * @return  Mage_Weee_Model_Total_Quote_Weee
  */
 protected function _processItem(Mage_Sales_Model_Quote_Address $address, $item, $updateParent = false)
 {
     $store = $address->getQuote()->getStore();
     if (!$this->_helper->isEnabled($store)) {
         return $this;
     }
     $custTaxClassId = $address->getQuote()->getCustomerTaxClassId();
     $taxCalculationModel = Mage::getSingleton('tax/calculation');
     /* @var $taxCalculationModel Mage_Tax_Model_Calculation */
     $request = $taxCalculationModel->getRateRequest($address, $address->getQuote()->getBillingAddress(), $custTaxClassId, $store);
     $defaultRateRequest = $taxCalculationModel->getRateRequest(false, false, false, $store);
     $attributes = $this->_helper->getProductWeeeAttributes($item->getProduct(), $address, $address->getQuote()->getBillingAddress(), $store->getWebsiteId());
     $applied = array();
     $productTaxes = array();
     foreach ($attributes as $k => $attribute) {
         $baseValue = $attribute->getAmount();
         $value = $store->convertPrice($baseValue);
         $rowValue = $value * $item->getQty();
         $baseRowValue = $baseValue * $item->getQty();
         $title = $attribute->getName();
         /**
          * Apply discount to fixed tax
          */
         if ($item->getDiscountPercent() && $this->_helper->isDiscounted($store)) {
             $valueDiscount = $value / 100 * $item->getDiscountPercent();
             $baseValueDiscount = $baseValue / 100 * $item->getDiscountPercent();
             $rowValueDiscount = $rowValue / 100 * $item->getDiscountPercent();
             $baseRowValueDiscount = $baseRowValue / 100 * $item->getDiscountPercent();
             $address->setDiscountAmount($address->getDiscountAmount() + $rowValueDiscount);
             $address->setBaseDiscountAmount($address->getBaseDiscountAmount() + $baseRowValueDiscount);
             $address->setGrandTotal($address->getGrandTotal() - $rowValueDiscount);
             $address->setBaseGrandTotal($address->getBaseGrandTotal() - $baseRowValueDiscount);
         }
         $oneDisposition = $baseOneDisposition = $disposition = $baseDisposition = 0;
         /**
          * Apply tax percent to fixed tax
          */
         if ($this->_helper->isTaxable($store)) {
             $currentPercent = $item->getTaxPercent();
             $defaultPercent = $taxCalculationModel->getRate($defaultRateRequest->setProductClassId($item->getProduct()->getTaxClassId()));
             $valueBeforeVAT = $rowValue;
             $baseValueBeforeVAT = $baseRowValue;
             $oneDisposition = $store->roundPrice($value / (100 + $defaultPercent) * $currentPercent);
             $baseOneDisposition = $store->roundPrice($baseValue / (100 + $defaultPercent) * $currentPercent);
             $disposition = $store->roundPrice($rowValue / (100 + $defaultPercent) * $currentPercent);
             $baseDisposition = $store->roundPrice($baseRowValue / (100 + $defaultPercent) * $currentPercent);
             $item->setBaseTaxAmount($item->getBaseTaxAmount() + $baseDisposition);
             $item->setTaxAmount($item->getTaxAmount() + $disposition);
             $value -= $oneDisposition;
             $baseValue -= $baseOneDisposition;
             $rowValue -= $baseDisposition;
             $baseRowValue -= $disposition;
             $item->setWeeeTaxDisposition($item->getWeeeTaxDisposition() + $oneDisposition);
             $item->setBaseWeeeTaxDisposition($item->getBaseWeeeTaxDisposition() + $baseOneDisposition);
             $item->setWeeeTaxRowDisposition($item->getWeeeTaxRowDisposition() + $disposition);
             $item->setBaseWeeeTaxRowDisposition($item->getBaseWeeeTaxRowDisposition() + $baseDisposition);
             //                $item->setTaxBeforeDiscount($item->getTaxBeforeDiscount() + $disposition);
             //                $item->setBaseTaxBeforeDiscount($item->getBaseTaxBeforeDiscount() + $baseDisposition);
             $address->setTaxAmount($address->getTaxAmount() + $disposition);
             $address->setBaseTaxAmount($address->getBaseTaxAmount() + $baseDisposition);
             $rate = $taxCalculationModel->getRate($request->setProductClassId($item->getProduct()->getTaxClassId()));
             $this->_saveAppliedTaxes($address, $taxCalculationModel->getAppliedRates($request), $store->roundPrice($valueBeforeVAT - $rowValue), $store->roundPrice($baseValueBeforeVAT - $baseRowValue), $rate);
             $address->setGrandTotal($address->getGrandTotal() + $store->roundPrice($valueBeforeVAT - $rowValue));
             $address->setBaseGrandTotal($address->getBaseGrandTotal() + $store->roundPrice($baseValueBeforeVAT - $baseRowValue));
         }
         /**
          * Check if need include fixed tax amount to subtotal
          */
         if ($this->_helper->includeInSubtotal($store)) {
             $address->setSubtotal($address->getSubtotal() + $rowValue);
             $address->setBaseSubtotal($address->getBaseSubtotal() + $baseRowValue);
             //                $address->setSubtotalWithDiscount($address->getSubtotalWithDiscount() + $rowValue);
             //                $address->setBaseSubtotalWithDiscount($address->getBaseSubtotalWithDiscount() + $baseRowValue);
         } else {
             $address->setTaxAmount($address->getTaxAmount() + $rowValue);
             $address->setBaseTaxAmount($address->getBaseTaxAmount() + $baseRowValue);
         }
         $productTaxes[] = array('title' => $title, 'base_amount' => $baseValue, 'amount' => $value, 'row_amount' => $rowValue, 'base_row_amount' => $baseRowValue, 'base_amount_incl_tax' => $baseValue + $baseOneDisposition, 'amount_incl_tax' => $value + $oneDisposition, 'row_amount_incl_tax' => $rowValue + $disposition, 'base_row_amount_incl_tax' => $baseRowValue + $baseDisposition);
         $applied[] = array('id' => $attribute->getCode(), 'percent' => null, 'hidden' => $this->_helper->includeInSubtotal($store), 'rates' => array(array('amount' => $rowValue, 'base_amount' => $baseRowValue, 'base_real_amount' => $baseRowValue, 'code' => $attribute->getCode(), 'title' => $title, 'percent' => null, 'position' => 1, 'priority' => -1000 + $k)));
         $item->setBaseWeeeTaxAppliedAmount($item->getBaseWeeeTaxAppliedAmount() + $baseValue);
         $item->setBaseWeeeTaxAppliedRowAmount($item->getBaseWeeeTaxAppliedRowAmount() + $baseRowValue);
         $item->setWeeeTaxAppliedAmount($item->getWeeeTaxAppliedAmount() + $value);
         $item->setWeeeTaxAppliedRowAmount($item->getWeeeTaxAppliedRowAmount() + $rowValue);
     }
     $this->_helper->setApplied($item, array_merge($this->_helper->getApplied($item), $productTaxes));
     if ($updateParent) {
         $parent = $item->getParentItem();
         $parent->setBaseWeeeTaxDisposition($parent->getBaseWeeeTaxDisposition() + $item->getBaseWeeeTaxDisposition());
         $parent->setWeeeTaxDisposition($parent->getWeeeTaxDisposition() + $item->getWeeeTaxDisposition());
         $parent->setBaseWeeeTaxRowDisposition($parent->getBaseWeeeTaxRowDisposition() + $item->getBaseWeeeTaxRowDisposition());
         $parent->setWeeeTaxRowDisposition($parent->getWeeeTaxRowDisposition() + $item->getWeeeTaxRowDisposition());
//.........这里部分代码省略.........
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:101,代码来源:Weee.php

示例2: 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

示例3: 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


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