/** * Removes error statuses from quote and item, set by this observer * * @param Mage_Sales_Model_Quote_Item $item * @param string $origin * @param int $code * @return Jarlssen_CustomCartValidation_Model_Observer */ protected function _removeErrorsFromQuoteAndItem($item, $origin, $code) { if ($item->getHasError()) { $params = array('origin' => $origin, 'code' => $code); $item->removeErrorInfosByParams($params); } $quote = $item->getQuote(); $quoteItems = $quote->getItemsCollection(); $canRemoveErrorFromQuote = true; foreach ($quoteItems as $quoteItem) { if ($quoteItem->getItemId() == $item->getItemId()) { continue; } $errorInfos = $quoteItem->getErrorInfos(); foreach ($errorInfos as $errorInfo) { if ($errorInfo['code'] == $code) { $canRemoveErrorFromQuote = false; break; } } if (!$canRemoveErrorFromQuote) { break; } } if ($quote->getHasError() && $canRemoveErrorFromQuote) { $params = array('origin' => $origin, 'code' => $code); $quote->removeErrorInfosByParams(null, $params); } return $this; }
/** * Removes error statuses from quote and item, set by this observer * * @param Mage_Sales_Model_Quote_Item $item * @param int $code * @return Mage_CatalogInventory_Model_Observer */ protected function _removeErrorsFromQuoteAndItem($item, $code) { //if(ITwebexperts_Payperrentals_Helper_Data::isReservationType($item->getProduct()) && ($item->getProduct()->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_CONFIGURABLE || $item->getProduct()->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE || $item->getProduct()->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_GROUPED)){ // return $this; //} if ($item->getHasError()) { $params = array('origin' => 'cataloginventory', 'code' => $code); $item->removeErrorInfosByParams($params); } $quote = $item->getQuote(); $quoteItems = $quote->getItemsCollection(); $canRemoveErrorFromQuote = true; foreach ($quoteItems as $quoteItem) { if ($quoteItem->getItemId() == $item->getItemId()) { continue; } $errorInfos = $quoteItem->getErrorInfos(); foreach ($errorInfos as $errorInfo) { if ($errorInfo['code'] == $code) { $canRemoveErrorFromQuote = false; break; } } if (!$canRemoveErrorFromQuote) { break; } } if ($quote->getHasError() && $canRemoveErrorFromQuote) { $params = array('origin' => 'cataloginventory', 'code' => $code); $quote->removeErrorInfosByParams(null, $params); } return $this; }
public function importQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem) { $this->_quote = $quoteItem->getQuote(); $this->setQuoteItem($quoteItem)->setQuoteItemId($quoteItem->getId())->setProductId($quoteItem->getProductId())->setProduct($quoteItem->getProduct())->setSku($quoteItem->getSku())->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; }
/** * Fetches the item price that should be used for calculating max catalog points spending * for the given item. Uses the following check hierarchy: * CustomPrice * > if not set use item price * > if not set use product final price * > if not set use * * @param Mage_Sales_Model_Quote_Item $item */ public function getItemProductPrice($item) { // Prepare data from item and initalize counters $store_currency = (double) $this->getCurrencyRate($item->getQuote()); if ($item->hasCustomPrice()) { $product_price = (double) $item->getCustomPrice() * $store_currency; } elseif (Mage::helper('tax')->priceIncludesTax() && ($item->getRowTotalBeforeRedemptions() && $item->getRowTotal())) { $rt = (double) $item->getRowTotal(); $item->setRowTotal($item->getRowTotalBeforeRedemptions()); $product_price = (double) Mage::helper('checkout')->getPriceInclTax($item); $item->setRowTotal($rt); } else { // item doesn't have a price, use the item product final price $item_price = (double) $item->getPrice(); $item_price = !empty($item_price) ? $item->getPrice() : $item->getProduct()->getFinalPrice(); $product_price = (double) $item_price * $store_currency; } return $product_price; }
/** * 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; }
/** * Add error info to the item and quote the item belongs to with the * provided error code and messages. * * @param Mage_Sales_Model_Quote_Item * @param int * @param string * @param string * @return self */ protected function _addErrorInfoForItem(Mage_Sales_Model_Quote_Item $item, $errorCode, $itemMessage, $quoteMessage) { $item->addErrorInfo(self::ERROR_INFO_SOURCE, $errorCode, $itemMessage); $parentItem = $item->getParentItem(); if ($parentItem) { $parentItem->addErrorInfo(self::ERROR_INFO_SOURCE, $errorCode, $itemMessage); } $item->getQuote()->addErrorInfo(self::ERROR_INFO_TYPE, self::ERROR_INFO_SOURCE, $errorCode, $quoteMessage); return $this; }
/** * Add error info to the item and quote the item belongs to with the * provided error code and messages. * * @param Mage_Sales_Model_Quote_Item * @param int * @param string * @param string * @return self */ protected function _addErrorInfoForItem(Mage_Sales_Model_Quote_Item $item, $errorCode, $itemMessage, $quoteMessage) { $item->addErrorInfo(EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_SOURCE, $errorCode, $itemMessage); $parentItem = $item->getParentItem(); if ($parentItem) { $parentItem->addErrorInfo(EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_SOURCE, $errorCode, $itemMessage); } $item->getQuote()->addErrorInfo(EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_TYPE, EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_SOURCE, $errorCode, $quoteMessage); return $this; }
/** * Return vendor ID for quote item based on requested qty * * if $qty===true, always return dropship vendor id * if $qty===false, always return local vendor id * otherwise return local vendor if enough qty in stock * * @param Mage_Sales_Model_Quote_Item $item * @param integer|boolean $qty * @return integer * @deprecated since 1.6.0 */ public function getQuoteItemVendor($item, $qty = 0) { $product = $item->getProduct(); if (!$product || !$product->hasUdropshipVendor()) { // if not available, load full product info to get product vendor $product = Mage::getModel('catalog/product')->load($item->getProductId()); } $store = $item->getQuote() ? $item->getQuote()->getStore() : $item->getOrder()->getStore(); $localVendorId = $this->getLocalVendorId($store); $vendorId = $product->getUdropshipVendor(); // product doesn't have vendor specified OR force local vendor if (!$vendorId || $qty === false) { return $localVendorId; } // force real vendor if ($qty === true) { return $vendorId; } // local stock is available if (Mage::getSingleton('udropship/stock_availability')->getUseLocalStockIfAvailable($store, $vendorId) && $product->getStockItem()->checkQty($qty)) { return $localVendorId; } // all other cases return $vendorId; }
/** * 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)); } } }
/** * Adds all items in the cart to the request * * @param Mage_Sales_Model_Quote_Item $item * @return int */ protected function _addItemsInCart($item) { if ($item->getAddress() instanceof Mage_Sales_Model_Quote_Address) { $items = $item->getAddress()->getAllItems(); } elseif ($item->getQuote() instanceof Mage_Sales_Model_Quote) { $items = $item->getQuote()->getAllItems(); } else { $items = array(); } if (count($items) > 0) { $this->_initProductCollection($items); $this->_initTaxClassCollection($item->getAddress()); foreach ($items as $item) { /** @var Mage_Sales_Model_Quote_Item $item */ $this->_newLine($item); } $this->_request->setLines($this->_lines); } return count($this->_lines); }
/** * Returns a total discount on the cart from the provided items * * @param Mage_Sales_Model_Quote_Item $item * @param Mage_Sales_Model_Quote_Address $address * @param TBT_Rewards_Model_Sales_Rule $rule * @param array() &$cartRules * @param int $qty max discount qty or unlimited if null * @return array($discountAmount, $baseDiscountAmount) */ protected function _getTotalPercentDiscountOnitem($item, $address, $rule, &$cartRules, $qty = null) { $quote = $item->getQuote(); $store = $item->getQuote()->getStore(); $rulePercent = $this->_getRulePercent($rule); $quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]); $quoteAmountBase = $cartRules[$rule->getId()]; list($item_row_total, $item_base_row_total) = $this->_getDiscountableRowTotal($address, $item, $rule); $discountAmount = $item_row_total * $rulePercent; $baseDiscountAmount = $item_base_row_total * $rulePercent; return array($discountAmount, $baseDiscountAmount); }
/** * Returns a total discount on the cart from the provided items * @deprecated @see TBT_Rewards_Model_Salesrule_Discount_Action_Cartfixed * * @param Mage_Sales_Model_Quote_Item $item * @param Mage_Sales_Model_Quote_Address $address * @param TBT_Rewards_Model_Sales_Rule $rule * @param array() &$cartRules * @return array($discountAmount, $baseDiscountAmount) */ protected function _getTotalFixedDiscountOnitem($item, $address, $rule, &$cartRules) { $quote = $item->getQuote(); $store = $item->getQuote()->getStore(); $quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]); if ($rule->getPointsAction() == TBT_Rewards_Model_Salesrule_Actions::ACTION_DISCOUNT_BY_POINTS_SPENT) { $points_spent = Mage::getSingleton('rewards/session')->getPointsSpending(); $multiplier = floor($points_spent / $rule->getPointsAmount()); } else { $multiplier = 1; } $quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]); if (Mage::helper('tax')->discountTax($store) && !Mage::helper('tax')->applyTaxAfterDiscount($store)) { $tax_amount = $item->getTaxAmount(); $base_tax_amount = $item->getBaseTaxAmount(); } else { $tax_amount = 0; $base_tax_amount = 0; } if (Mage::helper('rewards')->isBaseMageVersionAtLeast('1.4.2')) { $itemPrice = $this->_getItemPrice($item); $baseItemPrice = $this->_getItemBasePrice($item); $qty = $this->_getItemQty($item, $rule); if (1 >= $this->_rulesItemTotals[$rule->getId()]['items_count']) { $quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]); $discountAmount = min($itemPrice * $qty, $quoteAmount); $baseDiscountAmount = min($baseItemPrice * $qty, $cartRules[$rule->getId()]); } else { $discountRate = $baseItemPrice * $qty / $this->_rulesItemTotals[$rule->getId()]['base_items_price']; $maximumItemDiscount = $rule->getDiscountAmount() * $discountRate; $quoteAmount = $quote->getStore()->convertPrice($maximumItemDiscount); $discountAmount = min($itemPrice * $qty, $quoteAmount); $baseDiscountAmount = min($baseItemPrice * $qty, $maximumItemDiscount); $this->_rulesItemTotals[$rule->getId()]['items_count']--; } } else { $discountAmount = min($item->getRowTotal() - $item->getDiscountAmount() + $tax_amount, $quoteAmount); $baseDiscountAmount = min($item->getBaseRowTotal() - $item->getBaseDiscountAmount() + $base_tax_amount, $cartRules[$rule->getId()]); } return array($discountAmount, $baseDiscountAmount); }
/** * 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; }
/** * Returns a total discount on the cart from the provided items * * @param Mage_Sales_Model_Quote_Item $item * @param Mage_Sales_Model_Quote_Address $address * @param TBT_Rewards_Model_Sales_Rule $rule * @param array() &$cartRules * @return array($discountAmount, $baseDiscountAmount) */ protected function _getTotalFixedDiscountOnitem($item, $address, $rule, &$cartRules) { $quote = $item->getQuote(); $store = $item->getQuote()->getStore(); if ($rule->getPointsAction() == TBT_Rewards_Model_Salesrule_Actions::ACTION_DISCOUNT_BY_POINTS_SPENT) { $points_spent = Mage::getSingleton('rewards/session')->getPointsSpending(); $multiplier = floor($points_spent / $rule->getPointsAmount()); } else { $multiplier = 1; } $quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]); list($item_row_total, $item_base_row_total) = $this->_getDiscountableRowTotal($address, $item, $rule); $discountAmount = min($item_row_total, $quoteAmount); $baseDiscountAmount = min($item_base_row_total, $cartRules[$rule->getId()]); return array($discountAmount, $baseDiscountAmount); }
/** * 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 = count($this->_lines); $storeId = $item->getQuote()->getStoreId(); //Add gift wrapping price(for individual items) $gwItemsAmount = $item->getGwBasePrice() * $item->getQty(); $line = new Line(); $line->setNo($lineNumber); $gwItemsSku = $this->_getConfigHelper()->getGwItemsSku($storeId); $line->setItemCode($gwItemsSku ? $gwItemsSku : 'GwItemsAmount'); $line->setDescription('Gift Wrap Items Amount'); $line->setTaxCode($this->_getGiftTaxClassCode($storeId)); $line->setQty($item->getQty()); $line->setAmount($gwItemsAmount); $line->setDiscounted(false); if ($this->_getTaxDataHelper()->priceIncludesTax($storeId)) { $line->setTaxIncluded(true); } $this->_lines[$lineNumber] = $line; $this->_request->setLines($this->_lines); $this->_lineToLineId[$lineNumber] = $this->_getConfigHelper()->getGwItemsSku($storeId); $this->_productGiftPair[$lineNumber] = $item->getId(); return $lineNumber; }
/** * Removes error statuses from quote and item, set by this observer * * @param Mage_Sales_Model_Quote_Item $item * @param int $code * @return Mage_CatalogInventory_Model_Observer */ protected function _removeErrorsFromQuoteAndItem($item, $code) { if ($item->getHasError()) { $params = array('origin' => 'cataloginventory', 'code' => $code); $item->removeErrorInfosByParams($params); } $quote = $item->getQuote(); if ($quote->getHasError()) { $params = array('origin' => 'cataloginventory', 'code' => $code); $quote->removeErrorInfosByParams(null, $params); } return $this; }
/** * Add error info to the item and quote the item belongs to with the * provided error code and messages. * * @param Mage_Sales_Model_Quote_Item * @param int * @param string * @param string * @return self */ protected function _addErrorInfoForItem(Mage_Sales_Model_Quote_Item $item, $errorCode, $itemMessage, $quoteMessage) { $item->addErrorInfo(EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_SOURCE, $errorCode, $itemMessage); foreach ($item->getChildren() as $child) { $child->addErrorInfo(EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_SOURCE, $errorCode, $itemMessage); } $item->getQuote()->addErrorInfo(EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_TYPE, EbayEnterprise_Inventory_Model_Quantity_Service::ERROR_INFO_SOURCE, $errorCode, $quoteMessage); return $this; }
/** * * @param Mage_Sales_Model_Quote $quote * @param Mage_Sales_Model_Quote_Address $address * @param Mage_Sales_Model_Quote_Item $item * @param int $rule_id */ public function getNewDiscounts($quote, $address, $item, $rule_id) { $rule = $this->getRule($rule_id); $store = $item->getQuote()->getStore(); //@nelkaake 17/03/2010 5:01:35 AM if (!$this->_getDiscountValidator()->isValidAppliedRedemption($rule, $item)) { return $this->_emptyDiscount(); } //@nelkaake -a 16/11/10: No rule ID? if (!$rule->getId()) { throw new Exception("No rule ID was detected in Salesrule_Discount_Calculator::getNewDiscounts, which means that there may be some unexpected behaviour that may cause problems."); } //@nelkaake -a 11/03/11: if this item is valid for the rule if (!$rule->getActions()->validate($item)) { return $this->_emptyDiscount(); } $qty = $item->getQty(); //@nelkaake -a 11/03/11: If we have a bundle of 2, and two bundles it's 2x2=4 products total. if ($item->getParentItem()) { $qty *= $item->getParentItem()->getQty(); } //@nelkaake -a 11/03/11: Is there a maximum quantity to discount? If so, use that. TODO check if this is required. $qty = $rule->getDiscountQty() ? min($qty, $rule->getDiscountQty()) : $qty; //@nelkaake -a 11/03/11: Make sure there discount percent is 100% max. $rulePercent = min(100, $rule->getDiscountAmount()); //@nelkaake -a 11/03/11: Initialize the discount amounts $discountAmount = 0; $baseDiscountAmount = 0; //@nelkaake 17/03/2010 5:09:27 AM :Get all items. $all_items = $item->getQuote()->getAllItems(); //@nelkaake -a 11/03/11: How much was the total shipping amount so far? $shipping_amount = $address->getShippingAmount(); $base_shipping_amount = $address->getBaseShippingAmount(); //@nelkaake -a 11/03/11: Initialize the per-item price. $itemPrice = $item->getDiscountCalculationPrice(); if ($itemPrice !== null) { $baseItemPrice = $item->getBaseDiscountCalculationPrice(); } else { $itemPrice = $item->getCalculationPrice(); $baseItemPrice = $item->getBaseCalculationPrice(); } $cartRules = $address->getRewardsCartRules(); $cartRules = empty($cartRules) ? array() : $cartRules; // WDCA CODE BEGIN //@nelkaake -a 11/03/11: Before we begin, refactor all the catalog redemptions so we have the latest row totals. // TODO Is this still needed? switch ($rule->getSimpleAction()) { case 'by_percent': $by_percent_discounter = Mage::getSingleton('rewards/salesrule_discount_action_bypercent'); list($discountAmount, $baseDiscountAmount) = $by_percent_discounter->applyDiscounts($cartRules, $address, $item, $rule, $qty); break; case 'cart_fixed': $cart_fixed_discounter = Mage::getSingleton('rewards/salesrule_discount_action_cartfixed'); list($discountAmount, $baseDiscountAmount) = $cart_fixed_discounter->applyDiscounts($cartRules, $address, $item, $rule, $qty); // WDCA CODE END break; default: throw new Exception("Reached unsupported discount action. This may be due to corrupt data. Unexpected rule action was: " . $rule->getSimpleAction()); break; } //@nelkaake -a 11/03/11: Save cart rule entries. $address->setRewardsCartRules($cartRules); $discountAmount = $quote->getStore()->roundPrice($discountAmount); $baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount); return new Varien_Object(array('discount_amount' => $discountAmount, 'base_discount_amount' => $baseDiscountAmount)); }