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


PHP Mage_Sales_Model_Quote_Item::getQty方法代码示例

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


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

示例1: validateStock

 /**
  * Validate stock of a quoteItem
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @param float                       $priceInclTax
  * @param float                       $priceExclTax
  * @return ShopgateCartItem $result
  */
 public function validateStock(Mage_Sales_Model_Quote_Item $item, $priceInclTax, $priceExclTax)
 {
     /** @var Mage_Catalog_Model_Product $product */
     $product = $item->getProduct();
     /** @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
     $stockItem = $product->getStockItem();
     $isBuyable = true;
     if ($product->isConfigurable()) {
         $parent = $product;
         $product = $product->getCustomOption('simple_product')->getProduct();
         $product->setShopgateItemNumber($parent->getShopgateItemNumber());
         $product->setShopgateOptions($parent->getShopgateOptions());
         $product->setShopgateInputs($parent->getShopgateInputs());
         $product->setShhopgateAttributes($parent->getShhopgateAttributes());
         $stockItem = $item->getProduct()->getCustomOption('simple_product')->getProduct()->getStockItem();
     }
     $errors = array();
     if (Mage::helper('shopgate/config')->getIsMagentoVersionLower1410()) {
         $checkIncrements = Mage::helper('shopgate')->checkQtyIncrements($stockItem, $item->getQty());
     } else {
         $checkIncrements = $stockItem->checkQtyIncrements($item->getQty());
     }
     if ($stockItem->getManageStock() && !$product->isSaleable() && (!$stockItem->getBackorders() || !$stockItem->getIsInStock())) {
         $isBuyable = false;
         $error = array();
         $error['type'] = ShopgateLibraryException::CART_ITEM_OUT_OF_STOCK;
         $error['message'] = ShopgateLibraryException::getMessageFor(ShopgateLibraryException::CART_ITEM_OUT_OF_STOCK);
         $errors[] = $error;
     } else {
         if ($stockItem->getManageStock() && !$stockItem->checkQty($item->getQty()) && !$stockItem->getBackorders()) {
             $isBuyable = false;
             $error = array();
             $error['type'] = ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE;
             $error['message'] = ShopgateLibraryException::getMessageFor(ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE);
             $errors[] = $error;
         } else {
             if ($stockItem->getManageStock() && $checkIncrements->getHasError()) {
                 $isBuyable = false;
                 $error = array();
                 $error['type'] = ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE;
                 $error['message'] = ShopgateLibraryException::getMessageFor(ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE);
                 $errors[] = $error;
                 $stockItem->setQty((int) ($item->getQtyToAdd() / $stockItem->getQtyIncrements()) * $stockItem->getQtyIncrements());
             }
         }
     }
     $qtyBuyable = $isBuyable ? (int) $item->getQty() : (int) $stockItem->getQty();
     return Mage::helper('shopgate')->generateShopgateCartItem($product, $isBuyable, $qtyBuyable, $priceInclTax, $priceExclTax, $errors, (int) $stockItem->getQty());
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:57,代码来源:Simple.php

示例2: getEddMessage

 /**
  * Get an estimated delivery message for a quote item.
  *
  * @param  Mage_Sales_Model_Quote_Item
  * @return string
  */
 public function getEddMessage(Mage_Sales_Model_Quote_Item $item)
 {
     /** @var string $singularOrPluralItem */
     $singularOrPluralItem = (int) $item->getQty() > 1 ? 's' : '';
     /** @var EbayEnterprise_Inventory_Model_Details_Item | Varien_Object | null $eddItem */
     $eddItem = $this->detailService->getDetailsForItem($item) ?: $this->inventoryHelper->getStreetDateForBackorderableItem($item);
     return $eddItem ? $this->inventoryHelper->__($this->inventoryConfig->estimatedDeliveryTemplate, $singularOrPluralItem, $eddItem->getDeliveryWindowFromDate()->format('m/d/y'), $eddItem->getDeliveryWindowToDate()->format('m/d/y')) : '';
 }
开发者ID:WinstonN,项目名称:magento-retail-order-management,代码行数:14,代码来源:Edd.php

示例3: importQuoteItem

 public function importQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem)
 {
     $this->setQuoteItemId($quoteItem->getId())->setProductId($quoteItem->getProductId())->setProduct($quoteItem->getProduct())->setSuperProductId($quoteItem->getSuperProductId())->setSuperProduct($quoteItem->getSuperProduct())->setSku($quoteItem->getSku())->setImage($quoteItem->getImage())->setName($quoteItem->getName())->setDescription($quoteItem->getDescription())->setWeight($quoteItem->getWeight())->setPrice($quoteItem->getPrice())->setCost($quoteItem->getCost());
     if (!$this->hasQty()) {
         $this->setQty($quoteItem->getQty());
     }
     $this->setQuoteItemImported(true);
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:9,代码来源:Item.php

示例4: validate

 /**
  * Implementation of the validation logic
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @return bool
  */
 public function validate($item)
 {
     $multipleNumber = $this->_helper->getMultipleQtyNumber();
     $qty = $item->getQty();
     //For example 100 % 10
     if ($qty % $multipleNumber != 0) {
         return false;
     }
     return true;
 }
开发者ID:Engr-Kaka,项目名称:MyCompany_ExampleValidation,代码行数:16,代码来源:ValidateMultipleQty.php

示例5: setQuoteItem

 public function setQuoteItem(Mage_Sales_Model_Quote_Item $item)
 {
     $this->setQuoteItemId($item->getId());
     $this->setQuoteId($item->getQuoteId());
     $this->setProductId($item->getProductId());
     $this->setStoreId($item->getStoreId());
     $this->setQty($item->getQty());
     $this->setIsActive(true);
     $expireDateTime = Mage::helper('zab_timedcart')->getExpireDatetime(now());
     $this->setExpireDatetime($expireDateTime);
     return $this;
 }
开发者ID:becchius,项目名称:fiordivaniglia,代码行数:12,代码来源:Item.php

示例6: validateStock

 /**
  * Validate stock of a quoteItem
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @param float                       $priceInclTax
  * @param float                       $priceExclTax
  *
  * @return ShopgateCartItem $result
  */
 public function validateStock(Mage_Sales_Model_Quote_Item $item, $priceInclTax, $priceExclTax)
 {
     $product = $item->getProduct();
     /** @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
     $stockItem = $product->getStockItem();
     $errors = array();
     $isBuyable = true;
     $qtyBuyable = null;
     foreach ($item->getChildren() as $childItem) {
         /** @var Mage_Catalog_Model_Product $childProduct */
         $childProduct = $childItem->getProduct();
         /** @var Mage_CatalogInventory_Model_Stock_Item $childStock */
         $childStock = $childProduct->getStockItem();
         if ($childStock->getManageStock() && !$childProduct->isSaleable() && !$childStock->getBackorders()) {
             $isBuyable = false;
             $error = array();
             $error['type'] = ShopgateLibraryException::CART_ITEM_OUT_OF_STOCK;
             $error['message'] = ShopgateLibraryException::getMessageFor(ShopgateLibraryException::CART_ITEM_OUT_OF_STOCK);
             $errors[] = $error;
         } else {
             if ($childStock->getManageStock() && !$childStock->checkQty($childItem->getQty()) && !$childStock->getBackorders()) {
                 $isBuyable = false;
                 $error = array();
                 $error['type'] = ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE;
                 $error['message'] = ShopgateLibraryException::getMessageFor(ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE);
                 $errors[] = $error;
                 if ($qtyBuyable == null || $qtyBuyable > $childStock->getQty()) {
                     $qtyBuyable = $childStock->getQty();
                 }
             } else {
                 if (Mage::helper('shopgate/config')->getIsMagentoVersionLower1410()) {
                     $checkIncrements = Mage::helper('shopgate')->checkQtyIncrements($childStock, $childItem->getQty());
                 } else {
                     $checkIncrements = $childStock->checkQtyIncrements($childItem->getQty());
                 }
                 if ($childStock->getManageStock() && $checkIncrements->getHasError()) {
                     $isBuyable = false;
                     $error = array();
                     $error['type'] = ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE;
                     $error['message'] = ShopgateLibraryException::getMessageFor(ShopgateLibraryException::CART_ITEM_REQUESTED_QUANTITY_NOT_AVAILABLE);
                     $errors[] = $error;
                     $stockItem->setQty((int) ($item->getQtyToAdd() / $stockItem->getQtyIncrements()) * $stockItem->getQtyIncrements());
                 }
             }
         }
     }
     $qtyBuyable = $qtyBuyable == null ? (int) $item->getQty() : (int) $qtyBuyable;
     return Mage::helper('shopgate')->generateShopgateCartItem($product, $isBuyable, $qtyBuyable, $priceInclTax, $priceExclTax, $errors, (int) $stockItem->getQty());
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:58,代码来源:Bundle.php

示例7: getBuyRequest

 /**
  * Use our own method to get buyRequest
  * @param Mage_Sales_Model_Quote_Item $salesItem
  * @return Varien_Object
  *
  */
 public function getBuyRequest($salesItem, $option = false)
 {
     if ($option) {
         $option = $salesItem->getOptionByCode('info_buyRequest');
         $buyRequest = new Varien_Object($option && $option->getValue() ? unserialize($option->getValue()) : null);
         $buyRequest->setOriginalQty($buyRequest->getQty())->setQty($salesItem->getQty() * 1);
         return $buyRequest;
     }
     $option = $salesItem->getProductOptionByCode('info_buyRequest');
     if (!$option) {
         $option = array();
     }
     $buyRequest = new Varien_Object($option);
     $buyRequest->setQty($salesItem->getQtyOrdered() * 1);
     return $buyRequest;
 }
开发者ID:bigtailbear14,项目名称:rosstheme,代码行数:22,代码来源:AW_Collpur_Helper_Data.php

示例8: checkProductmaxAmount

 /**
  * Check max amount after adding product to cart
  *
  * @param Mage_Sales_Model_Quote_Item $quoteItem
  */
 public function checkProductmaxAmount($quoteItem)
 {
     $quoteStore = $quoteItem->getStore();
     if ($this->isProductEnable($quoteStore)) {
         $maxAmount = $this->getCartMaxAmount($quoteStore);
         /* @var $quote Mage_Sales_Model_Quote */
         $quote = $quoteItem->getQuote();
         $grandTotal = $quote->getGrandTotal();
         $_product = Mage::getModel('catalog/product')->load($quoteItem->getProduct()->getId());
         $grandTotal += $_product->getFinalPrice($quoteItem->getQty());
         if ($grandTotal > $maxAmount) {
             $formater = new Varien_Filter_Template();
             $formater->setVariables(array('amount' => Mage::helper('core')->currency($maxAmount, true, false)));
             $format = $this->getProductMessage($quoteStore);
             // throw exception for "remove" product to cart
             Mage::throwException($formater->filter($format));
         }
     }
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:24,代码来源:Data.php

示例9: displayOriginalPriceInclTax

 /**
  * Returns the item's original price that includes tax
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @return double
  */
 public function displayOriginalPriceInclTax($item)
 {
     $tax = 0;
     if ($item->getTaxPercent()) {
         $tax = $item->getPrice() * ($item->getTaxPercent() / 100);
     }
     return $this->convertPrice($item->getPrice() + $tax / $item->getQty());
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:14,代码来源:Grid.php

示例10: checkQuoteItemQty

 /**
  * Check Quote item qty. If qty is not enougth for order, error flag and message added to $quote item
  *
  * @param Mage_Sales_Model_Quote_Item $quoteItem
  */
 protected function checkQuoteItemQty($quoteItem)
 {
     $qty = $quoteItem->getQty();
     if (($options = $quoteItem->getQtyOptions()) && $qty > 0) {
         $qty = $quoteItem->getProduct()->getTypeInstance(true)->prepareQuoteItemQty($qty, $quoteItem->getProduct());
         $quoteItem->setData('qty', $qty);
         foreach ($options as $option) {
             $optionQty = $qty * $option->getValue();
             $increaseOptionQty = ($quoteItem->getQtyToAdd() ? $quoteItem->getQtyToAdd() : $qty) * $option->getValue();
             $stockItem = $option->getProduct()->getStockItem();
             /* @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
             if (!$stockItem instanceof Mage_CatalogInventory_Model_Stock_Item) {
                 $quoteItem->setHasError(true)->setMessage('Stock item for Product in option is not valid');
                 return;
             }
             $result = $stockItem->checkQuoteItemQty($optionQty, $optionQty, $option->getValue());
             if ($result->getHasError()) {
                 $quoteItem->setHasError(true)->setMessage($result->getQuoteMessage());
             }
         }
     } else {
         $stockItem = $quoteItem->getProduct()->getStockItem();
         /* @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
         if (!$stockItem instanceof Mage_CatalogInventory_Model_Stock_Item) {
             Mage::throwException(Mage::helper('cataloginventory')->__('Stock item for Product is not valid'));
         }
         /**
          * When we work with subitem (as subproduct of bundle or configurable product)
          */
         if ($quoteItem->getParentItem()) {
             $rowQty = $quoteItem->getParentItem()->getQty() * $qty;
             /**
              * we are using 0 because original qty was processed
              */
             $qtyForCheck = 0;
         } else {
             $increaseQty = $quoteItem->getQtyToAdd() ? $quoteItem->getQtyToAdd() : $qty;
             $rowQty = $qty;
             $qtyForCheck = $qty;
         }
         $result = $stockItem->checkQuoteItemQty($rowQty, $qtyForCheck, $qty);
         if ($result->getHasError()) {
             $quoteItem->setHasError(true)->setMessage($result->getQuoteMessage());
         }
     }
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:51,代码来源:Create.php

示例11: addItem

 /**
  * Add new product to registry
  *
  * @param int|Mage_Sales_Model_Quote_Item $itemToAdd
  * @param Varien_Object $request
  * @return Enterprise_GiftRegistry_Model_Item
  */
 public function addItem($itemToAdd, $request = null)
 {
     if ($itemToAdd instanceof Mage_Sales_Model_Quote_Item) {
         $productId = $itemToAdd->getProductId();
         $qty = $itemToAdd->getQty();
     } else {
         $productId = $itemToAdd;
         $qty = $request && $request->getQty() ? $request->getQty() : 1;
     }
     $product = $this->getProduct($productId);
     if ($product->getTypeInstance(true)->hasRequiredOptions($product) && (!$request && !$itemToAdd instanceof Mage_Sales_Model_Quote_Item)) {
         throw new Mage_Core_Exception(null, self::EXCEPTION_CODE_HAS_REQUIRED_OPTIONS);
     }
     if ($itemToAdd instanceof Mage_Sales_Model_Quote_Item) {
         $cartCandidate = $itemToAdd->getProduct();
         $cartCandidate->setCustomOptions($itemToAdd->getOptionsByCode());
         $cartCandidates = array($cartCandidate);
     } else {
         if (!$request) {
             $request = new Varien_Object();
             $request->setBundleOption(array());
             //Bundle options mocking for compatibility
         }
         $cartCandidates = $product->getTypeInstance(true)->prepareForCart($request, $product);
     }
     if (is_string($cartCandidates)) {
         //prepare process has error, seems like we have bundle
         throw new Mage_Core_Exception($cartCandidates, self::EXCEPTION_CODE_HAS_REQUIRED_OPTIONS);
     }
     $item = Mage::getModel('enterprise_giftregistry/item');
     $items = $item->getCollection()->addRegistryFilter($this->getId());
     foreach ($cartCandidates as $currentCandidate) {
         if ($currentCandidate->getParentProductId()) {
             continue;
         }
         $alreadyExists = false;
         $productId = $currentCandidate->getId();
         foreach ($items as $itemForCheck) {
             if ($itemForCheck->isRepresentProduct($currentCandidate)) {
                 $alreadyExists = true;
                 $matchedItem = $itemForCheck;
                 break;
             }
         }
         $candidateQty = $currentCandidate->getCartQty();
         if (!empty($candidateQty)) {
             $qty = $candidateQty;
         }
         if ($alreadyExists) {
             $matchedItem->setQty($matchedItem->getQty() + $qty)->save();
         } else {
             $customOptions = $currentCandidate->getCustomOptions();
             $item = Mage::getModel('enterprise_giftregistry/item');
             $item->setEntityId($this->getId())->setProductId($productId)->setOptions($customOptions)->setQty($qty)->save();
         }
     }
     return $item;
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:65,代码来源:Entity.php

示例12: _addGwItemsAmount

 /**
  * Adds giftwrapitems cost to request as item
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @return int|bool
  */
 protected function _addGwItemsAmount($item)
 {
     if (!$item->getGwId()) {
         return false;
     }
     $lineNumber = $this->_getNewLineCode();
     $storeId = $item->getQuote()->getStoreId();
     //Add gift wrapping price(for individual items)
     $gwItemsAmount = $item->getGwBasePrice() * $item->getQty();
     $line = $this->_getNewDocumentRequestLineObject();
     $line->setLineCode($lineNumber);
     $gwItemsSku = $this->_getConfigHelper()->getGwItemsSku($storeId);
     $line->setItemCode($gwItemsSku ? $gwItemsSku : self::DEFAULT_GW_ITEMS_SKU);
     $line->setItemDescription(self::DEFAULT_GW_ITEMS_DESCRIPTION);
     $line->setAvalaraGoodsAndServicesType($this->_getGiftTaxClassCode($storeId));
     $line->setNumberOfItems($item->getQty());
     $line->setlineAmount($gwItemsAmount);
     $line->setDiscounted('false');
     if ($this->_getTaxDataHelper()->priceIncludesTax($storeId)) {
         $line->setTaxIncluded('true');
     }
     $this->_lines[$lineNumber] = $line;
     $this->_setLinesToRequest();
     $this->_lineToLineId[$lineNumber] = $this->_getConfigHelper()->getGwItemsSku($storeId);
     $this->_productGiftPair[$lineNumber] = $item->getId();
     return $lineNumber;
 }
开发者ID:onepica,项目名称:avatax,代码行数:33,代码来源:Estimate.php

示例13: setBundleParentWeight

 /**
  * Retrieves the fixed weight set on the parent item
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @param bool $cartFreeShipping is the cart marked as free shipping
  * @param Webshopapps_Wsacommon_Model_Totals $finalTotals the final totals model instance
  * @param bool $isParent is the $item the parent item or a child
  * @return bool success
  */
 private function setBundleParentWeight($item, $cartFreeShipping, &$finalTotals, $isParent = true)
 {
     $parentItem = $isParent ? $item : $item->getParentItem();
     if ($parentItem->getProduct()->getWeightType()) {
         $itemWeight = $parentItem->getProduct()->getWeight();
         $rowWeight = $itemWeight * $parentItem->getQty();
         if ($cartFreeShipping || $item->getFreeShipping() === true) {
             $rowWeight = 0;
         } elseif (is_numeric($item->getFreeShipping())) {
             $freeQty = $item->getFreeShipping();
             if ($item->getQty() > $freeQty) {
                 $rowWeight = $itemWeight * ($item->getQty() - $freeQty);
             } else {
                 $rowWeight = 0;
             }
         }
         $finalTotals->setWeight($rowWeight);
         $finalTotals->setFreeMethodWeight($rowWeight);
         return true;
     } else {
         return false;
     }
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:32,代码来源:Totals.php

示例14: checkQuoteItemQty

 /**
  * Checking quote item quantity
  *
  * @param   Mage_Sales_Model_Quote_Item $item
  * @return  Mage_CatalogInventory_Model_Stock_Item
  */
 public function checkQuoteItemQty(Mage_Sales_Model_Quote_Item $item)
 {
     $qty = $item->getQty();
     if (!is_numeric($qty)) {
         $qty = floatval($qty);
     }
     if (!$this->getIsInStock()) {
         $this->_addQuoteItemError($item, Mage::helper('cataloginventory')->__('This product is currently out of stock.'), Mage::helper('cataloginventory')->__('Some of the products are currently out of stock'), 'stock');
         $item->setUseOldQty(true);
         return $this;
     }
     if ($this->getMinSaleQty() && $qty < $this->getMinSaleQty()) {
         $this->_addQuoteItemError($item, Mage::helper('cataloginventory')->__('The minimum quantity allowed for purchase is %s.', $this->getMinSaleQty() * 1), Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in the requested quantity'), 'qty');
         return $this;
     }
     if ($this->getMaxSaleQty() && $qty > $this->getMaxSaleQty()) {
         $this->_addQuoteItemError($item, Mage::helper('cataloginventory')->__('The maximum quantity allowed for purchase is %s.', $this->getMaxSaleQty() * 1), Mage::helper('cataloginventory')->__('Some of the products can not be ordered in requested quantity'), 'qty');
         return $this;
     }
     if ($this->checkQty($qty)) {
         if ($this->getQty() - $qty < 0 && $this->getBackorders() == Mage_CatalogInventory_Model_Stock::BACKORDERS_YES) {
             if ($this->getProduct()) {
                 $item->setMessage(Mage::helper('cataloginventory')->__('This product is not available in the requested quantity. %s of the items will be backordered.', $this->getQty() > 0 ? ($qty - $this->getQty()) * 1 : $qty * 1, $this->getProduct()->getName()));
             }
         }
     }
     /**
      * Check quontity type
      */
     if (!$this->getIsQtyDecimal()) {
         $qty = intval($qty);
     }
     $item->setHasError(false);
     /**
      * Adding stock data to quote item
      */
     $item->addData(array('qty' => $qty, 'backorders' => $this->getBackorders()));
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:45,代码来源:Item.php

示例15: getUpdatedRedemptionData

 /**
  * Retenders the item's redemption rules and final row total and returns it.
  * @param Mage_Sales_Model_Quote_Item $item
  * @return array a map of the new item redemption data: 
  * array('redemptions_data'=>{...}, 'row_total'=>float)
  */
 protected function getUpdatedRedemptionData($item, $do_incl_tax = true)
 {
     // Step 1: Create a map of usability for all applied redemptions
     //echo "$item->getRedeemedPointsHash()";
     $redeemed_points = Mage::helper('rewards')->unhashIt($item->getRedeemedPointsHash());
     // Prepare data from item and initalize counters
     if ($item->getQuote()) {
         $store_currency = round($item->getQuote()->getStoreToQuoteRate(), 4);
     }
     if ($item->getOrder()) {
         $store_currency = round($item->getOrder()->getStoreToQuoteRate(), 4);
     }
     if ($item->hasCustomPrice()) {
         $product_price = (double) $item->getCustomPrice() * $store_currency;
     } else {
         //@nelkaake -a 17/02/11: We need to use our own calculation because the one that was set by the
         // rest of the Magento system is rounded.
         if (Mage::helper('tax')->priceIncludesTax() && $item->getPriceInclTax()) {
             $product_price = $item->getPriceInclTax() / (1 + $item->getTaxPercent() / 100);
         } else {
             $product_price = (double) $item->getPrice() * $store_currency;
         }
     }
     if ($item->getParentItem() || sizeof($redeemed_points) == 0) {
         return array('redemptions_data' => array(), 'row_total_incl_tax' => $item->getRowTotalInclTax(), 'row_total' => $item->getRowTotal());
     }
     $total_qty = $item->getQty();
     $total_qty_redeemed = 0.0;
     $row_total = 0.0;
     $new_redeemed_points = array();
     $ret = array();
     // Loop through and apply all our rules.
     foreach ($redeemed_points as $key => &$redemption_instance) {
         $redemption_instance = (array) $redemption_instance;
         $applic_qty = $redemption_instance[self::POINTS_APPLICABLE_QTY];
         $rule_id = $redemption_instance[self::POINTS_RULE_ID];
         $effect = $redemption_instance[self::POINTS_EFFECT];
         $uses = isset($redemption_instance[self::POINTS_USES]) ? (int) $redemption_instance[self::POINTS_USES] : 1;
         $rule = Mage::helper('rewards/rule')->getCatalogRule($rule_id);
         // If a rule was turned off at some point in the back-end it should be removed and not calculated in the cart anymore.
         if (!$rule->getIsActive()) {
             $this->removeCatalogRedemptionsFromItem($item, array($rule_id));
             $effect = "";
         }
         $total_qty_remain = $total_qty - $total_qty_redeemed;
         if ($total_qty_remain > 0) {
             if ($total_qty_remain < $applic_qty) {
                 $applic_qty = $total_qty_remain;
                 $redemption_instance[TBT_Rewards_Model_Redeem::POINTS_APPLICABLE_QTY] = $applic_qty;
             }
             $price_after_redem = $this->getPriceAfterEffect($product_price, $effect, $item);
             $row_total += $applic_qty * (double) $price_after_redem;
             $total_qty_redeemed += $applic_qty;
             $new_redeemed_points[] = $redemption_instance;
         } else {
             $redemption_instance[TBT_Rewards_Model_Catalogrule_Rule::POINTS_APPLICABLE_QTY] = 0;
             $redemption_instance[TBT_Rewards_Model_Catalogrule_Rule::POINTS_USES] = 1;
             // used once by default
             unset($redeemed_points[$key]);
         }
     }
     $ret['redemptions_data'] = $new_redeemed_points;
     // Add in the left over products that perhaps weren't affected by qty adjustment.
     $total_qty_remain = $total_qty - $total_qty_redeemed;
     if ($total_qty_remain < 0) {
         $total_qty_remain = 0;
         $total_qty_redeemed = $total_qty;
         //throw new Exception("Redemption rules may be overlapping.  Please notify the store administrator of this error.");
     }
     $row_total += $total_qty_remain * (double) $product_price;
     $ret['row_total'] = $row_total;
     $ret['row_total_incl_tax'] = $row_total * (1 + $item->getTaxPercent() / 100);
     return $ret;
 }
开发者ID:rajarshc,项目名称:Rooja,代码行数:80,代码来源:Redeem.php


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