protected function _buildUpdateResponse($controllerAction)
 {
     $result = $this->_buildCommonResponse($controllerAction, '%s was updated in your shopping cart.', 'Cannot update the item.');
     if ($this->_lastUpdatedItem !== null) {
         $result['product_addtocart_form_action'] = Mage::getUrl('checkout/cart/updateItemOptions', array('id' => $this->_lastUpdatedItem->getId()));
     }
     return $result;
 }
示例#2
0
 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;
 }
示例#3
0
 /**
  * Get gifregistry params by quote item
  *
  * @param Mage_Sales_Model_Quote_Item $newItem
  * @return Enterprise_GiftRegistry_Block_Cart_Product_Mark
  */
 public function setItem($newItem)
 {
     if ($this->hasItem() && $this->getItem()->getId() == $newItem->getId()) {
         return $this;
     }
     if ($newItem->getGiftregistryItemId()) {
         $this->setData('item', $newItem);
         $entity = Mage::getModel('enterprise_giftregistry/entity')->loadByEntityItem($newItem->getGiftregistryItemId());
         $this->setEntity($entity);
     }
     return $this;
 }
示例#4
0
 /**
  * Get button to configure product
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @return mixed
  */
 public function getConfigureButtonHtml($item)
 {
     $product = $item->getProduct();
     $options = array('label' => Mage::helper('sales')->__('Configure'));
     if ($product->canConfigure()) {
         $options['onclick'] = sprintf('orderEditItems.showQuoteItemConfiguration(%s)', $item->getId());
     } else {
         $options['class'] = ' disabled';
         $options['title'] = Mage::helper('sales')->__('This product does not have any configurable options');
     }
     return $this->getLayout()->createBlock('adminhtml/widget_button')->setData($options)->toHtml();
 }
示例#5
0
 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;
 }
示例#6
0
 /**
  * Overwrite @method _addItemToQtyArray
  *
  * Adds stock item qty to $items (creates new entry or increments existing one)
  * $items is array with following structure:
  * array(
  *  $productId  => array(
  *      'qty'   => $qty,
  *      'item'  => $stockItems|null
  *  )
  * )
  *
  * @param Mage_Sales_Model_Quote_Item $quoteItem
  * @param array &$items
  */
 protected function _addItemToQtyArray($quoteItem, &$items)
 {
     $productId = $quoteItem->getProductId();
     if (!$productId) {
         return;
     }
     if (isset($items[$productId])) {
         $items[$productId]['qty'] += $quoteItem->getTotalQty();
     } else {
         $stockItem = null;
         if ($quoteItem->getProduct()) {
             $stockItem = $quoteItem->getProduct()->getStockItem();
         }
         $items[$productId] = array('item' => $stockItem, 'qty' => $quoteItem->getTotalQty(), 'quote_item_id' => $quoteItem->getId(), 'creditmemo_item_id' => null);
     }
 }
 /**
  * Deal with the unavailable item. Mark the item as either out of stock
  * or unavailable in the requested quantity. If the item has not already
  * been added to cart, prevent it from being added.
  *
  * @param Mage_Sales_Model_Quote_Item
  * @param int
  * @return self
  * @throws EbayEnterprise_Inventory_Exception_Quantity_Unavailable If item should not be added to the quote
  */
 public function handleUnavailableItem(Mage_Sales_Model_Quote_Item $item, $quantityAvailable)
 {
     // Unavailable handler assumes that if an item is unavailable, it is
     // a manage stock and non-backorderable item (non-manage stock and
     // backorderable items will never be unavailable).
     $itemIsOutOfStock = $quantityAvailable === 0;
     // Items not already in the cart should not be added if unavailable.
     // Items without an id have not yet been saved and can not have been
     // added to the quote previously. Any item with an id, would have been
     // saved when initially added to the cart previously.
     if (!$item->getId()) {
         $message = $itemIsOutOfStock ? EbayEnterprise_Inventory_Model_Quantity_Service::OUT_OF_STOCK_EXCEPTION_MESSAGE : EbayEnterprise_Inventory_Model_Quantity_Service::INSUFFICIENT_STOCK_EXCEPTION_MESSAGE;
         throw Mage::exception('EbayEnterprise_Inventory_Exception_Quantity_Unavailable', $this->inventoryHelper->__($message, $item->getName(), $quantityAvailable));
     }
     return $itemIsOutOfStock ? $this->_addOutOutOfStockErrorInfo($item) : $this->_addInsufficientStockErrorInfoForItem($item, $quantityAvailable);
 }
示例#8
0
 /**
  * Adding new item to quote
  *
  * @param   Mage_Sales_Model_Quote_Item $item
  * @return  Mage_Sales_Model_Quote
  */
 function addItem(Mage_Sales_Model_Quote_Item $item)
 {
     // elite paint
     if (isset($_POST['paint'])) {
         if ('other' != $_POST['paint']) {
             $item->setElitePaint($_POST['paint']);
         } else {
             $item->setElitePaintOther($_POST['vafPaintCustom']);
         }
     }
     // elite paint
     $item->setQuote($this);
     if (!$item->getId()) {
         $this->getItemsCollection()->addItem($item);
         Mage::dispatchEvent('sales_quote_add_item', array('quote_item' => $item));
     }
     return $this;
 }
示例#9
0
 /**
  * IFrame handler for submitted configuration for quote item
  *
  * @return Mage_Adminhtml_Customer_Cart_Product_Composite_CartController
  */
 public function updateAction()
 {
     $updateResult = new Varien_Object();
     try {
         $this->_initData();
         $buyRequest = new Varien_Object($this->getRequest()->getParams());
         $this->_quote->updateItem($this->_quoteItem->getId(), $buyRequest);
         $this->_quote->collectTotals()->save();
         $updateResult->setOk(true);
     } catch (Exception $e) {
         $updateResult->setError(true);
         $updateResult->setMessage($e->getMessage());
     }
     $updateResult->setJsVarName($this->getRequest()->getParam('as_js_varname'));
     Mage::getSingleton('Mage_Adminhtml_Model_Session')->setCompositeProductResult($updateResult);
     $this->_redirect('*/catalog_product/showUpdateResult');
     return $this;
 }
示例#10
0
 /**
  * Makes a Line object from a product item object
  *
  * @param Varien_Object|Mage_Sales_Model_Quote_Item $item
  * @return int|bool
  */
 protected function _newLine($item)
 {
     if (!$item->getId()) {
         $this->setCanSendRequest(false);
         return $this;
     }
     $this->_addGwItemsAmount($item);
     if ($this->isProductCalculated($item)) {
         return false;
     }
     $product = $this->_getProductByProductId($this->_retrieveProductIdFromQuoteItem($item));
     $taxClass = $this->_getTaxClassCodeByProduct($product);
     $price = $item->getBaseRowTotal();
     if ($this->_getTaxDataHelper()->applyTaxAfterDiscount($item->getStoreId())) {
         $price = $item->getBaseRowTotal() - $item->getBaseDiscountAmount();
     }
     $lineNumber = count($this->_lines);
     $line = new Line();
     $line->setNo($lineNumber);
     $line->setItemCode($this->_getCalculationHelper()->getItemCode($this->_getProductForItemCode($item), $item->getStoreId()));
     $line->setDescription($item->getName());
     $line->setQty($item->getTotalQty());
     $line->setAmount($price);
     $line->setDiscounted((double) $item->getDiscountAmount() && $this->_getTaxDataHelper()->applyTaxAfterDiscount($item->getStoreId()));
     if ($this->_getTaxDataHelper()->priceIncludesTax($item->getStoreId())) {
         $line->setTaxIncluded(true);
     }
     if ($taxClass) {
         $line->setTaxCode($taxClass);
     }
     $ref1Value = $this->_getRefValueByProductAndNumber($product, 1, $item->getStoreId());
     if ($ref1Value) {
         $line->setRef1($ref1Value);
     }
     $ref2Value = $this->_getRefValueByProductAndNumber($product, 2, $item->getStoreId());
     if ($ref2Value) {
         $line->setRef2($ref2Value);
     }
     $this->_lines[$lineNumber] = $line;
     $this->_lineToLineId[$lineNumber] = $item->getId();
     return $lineNumber;
 }
示例#11
0
    /**
     * Convert quote item to private item XML
     *
     * @param Mage_Sales_Model_Quote_Item $item
     * @return string
     */
    protected function _getMerchantPrivateItemDataXml($item)
    {
        $xml = <<<EOT
            <merchant-private-item-data>
                <quote-item-id>{$item->getId()}</quote-item-id>
            </merchant-private-item-data>
EOT;
        return $xml;
    }
示例#12
0
 public function deleteByQuoteItemAndDates(Mage_Sales_Model_Quote_Item $QuoteItem, $start_date, $end_date)
 {
     $condition = "quote_item_id=" . intval($QuoteItem->getId()) . ' AND start_date="' . ITwebexperts_Payperrentals_Helper_Date::toDbDate($start_date) . '" AND end_date="' . ITwebexperts_Payperrentals_Helper_Date::toDbDate($end_date) . '"';
     $this->_getWriteAdapter()->delete($this->getMainTable(), $condition);
     return $this;
 }
 /**
  * Generate configure button html
  *
  * @param  Mage_Sales_Model_Quote_Item $item
  * @return string
  */
 public function getConfigureButtonHtml($item)
 {
     $product = $item->getProduct();
     if ($product->canConfigure()) {
         $class = '';
         $addAttributes = sprintf('onclick="checkoutObj.showQuoteItemConfiguration(%s)"', $item->getId());
     } else {
         $class = 'disabled';
         $addAttributes = 'disabled="disabled"';
     }
     return sprintf('<button type="button" class="scalable %s" %s><span><span><span>%s</span></span></span></button>', $class, $addAttributes, Mage::helper('sales')->__('Configure'));
 }
示例#14
0
 /**
  * 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;
 }
示例#15
0
 /**
  * Add active parent product from item.
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @return $this
  */
 public function addActiveItemParentProduct($item)
 {
     if ($item && $item->getId() && $item->getParentItemId()) {
         if ($item->getParentItem()->getProduct()->getTypeId() == 'configurable') {
             // for price calculations to become accurate we need to reload the product,
             // otherwise things like tier pricing won't be loaded on it and the calculations
             // will ne dup being incorrect.
             $this->_activeItemParentProducts[$item->getProduct()->getId()] = Mage::getModel('catalog/product')->load($item->getParentItem()->getProductId());
         }
     }
     return $this;
 }
示例#16
0
 public function deleteByQuoteItem(Mage_Sales_Model_Quote_Item $QuoteItem)
 {
     $condition = "otype='" . ITwebexperts_Payperrentals_Model_Reservationorders::TYPE_QUOTE . "' AND order_id=" . intval($QuoteItem->getId());
     $this->_getWriteAdapter()->delete($this->getMainTable(), $condition);
     return $this;
 }
示例#17
0
 /**
  * Adding new item to quote
  *
  * @param   Mage_Sales_Model_Quote_Item $item
  * @return  Mage_Sales_Model_Quote
  */
 public function addItem(Mage_Sales_Model_Quote_Item $item)
 {
     /**
      * Temporary workaround for purchase process: it is too dangerous to purchase more than one nominal item
      * or a mixture of nominal and non-nominal items, although technically possible.
      *
      * The problem is that currently it is implemented as sequential submission of nominal items and order, by one click.
      * It makes logically impossible to make the process of the purchase failsafe.
      * Proper solution is to submit items one by one with customer confirmation each time.
      */
     if ($item->isNominal() && $this->hasItems() || $this->hasNominalItems()) {
         Mage::throwException(Mage::helper('sales')->__('Nominal item can be purchased standalone only. To proceed please remove other items from the quote.'));
     }
     $item->setRemoteInstallation($_REQUEST['remote_installation']);
     $item->setQuote($this);
     if (!$item->getId()) {
         $this->getItemsCollection()->addItem($item);
         Mage::dispatchEvent('sales_quote_add_item', array('quote_item' => $item));
     }
     return $this;
 }
示例#18
0
 /**
  * Adding new item to quote
  *
  * @param   Mage_Sales_Model_Quote_Item $item
  * @return  Mage_Sales_Model_Quote
  */
 public function addItem(Mage_Sales_Model_Quote_Item $item)
 {
     $item->setQuote($this)->setParentId($this->getId());
     if (!$item->getId()) {
         $this->getItemsCollection()->addItem($item);
     }
     return $this;
 }
示例#19
0
 public function getItemDeleteUrl(Mage_Sales_Model_Quote_Item $item)
 {
     return $this->getUrl('checkout/cart/delete', array('id' => $item->getId()));
 }
示例#20
0
 /**
  * override for changing the current stock qty based on the quote_item
  * (this is a bad design from Magento, checkQuoteItemQty should receive the quoteItem in the original code too)
  *
  * @param mixed $qty
  * @param mixed $summaryQty
  * @param int $origQty
  * @param Mage_Sales_Model_Quote_Item $quoteItem
  *
  * @return Varien_Object
  */
 public function checkQuoteItemQty($qty, $summaryQty, $origQty = 0, $quoteItem = null, $product = null)
 {
     if ($quoteItem && ITwebexperts_Payperrentals_Helper_Data::isReservationOnly($product) && (!$quoteItem->getChildren() || Mage::app()->getStore()->isAdmin())) {
         $qtyOption = 1;
         if ($quoteItem->getParentProductQty()) {
             $qty = $quoteItem->getParentProductQty();
             $qtyOption = $quoteItem->getParentProductQtyOption();
         }
         $quoteItemId = $quoteItem->getId();
         if ($quoteItem->getParentItem() && $quoteItem->getParentItem()->getProduct()) {
             if ($quoteItem->getParentItem()->getProduct()->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE) {
                 $quoteItemId = $quoteItem->getParentItem()->getItemId();
             }
         }
         $turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($product, $quoteItem);
         list($startDate, $endDate) = array($turnoverArr['before'], $turnoverArr['after']);
         $result = new Varien_Object();
         $result->setHasError(false);
         if (!is_numeric($qty)) {
             $qty = Mage::app()->getLocale()->getNumber($qty);
         }
         /**
          * Check quantity type
          */
         $result->setItemIsQtyDecimal($this->getIsQtyDecimal());
         if (!$this->getIsQtyDecimal()) {
             $result->setHasQtyOptionUpdate(true);
             $qty = intval($qty);
             /**
              * Adding stock data to quote item
              */
             $result->setItemQty($qty);
             if (!is_numeric($qty)) {
                 $qty = Mage::app()->getLocale()->getNumber($qty);
             }
             $origQty = intval($origQty);
             $result->setOrigQty($origQty);
         }
         if ($qty < ITwebexperts_Payperrentals_Helper_Inventory::getMinSaleQuantity($product)) {
             $result->setHasError(true)->setMessage(Mage::helper('cataloginventory')->__('The minimum quantity allowed for purchase is %s.', ITwebexperts_Payperrentals_Helper_Inventory::getMinSaleQuantity($product)))->setErrorCode('qty_min')->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in requested quantity.'))->setQuoteMessageIndex('qty');
             return $result;
         }
         if ($qty > ITwebexperts_Payperrentals_Helper_Inventory::getMaxSaleQuantity($product)) {
             $result->setHasError(true)->setMessage(Mage::helper('cataloginventory')->__('The maximum quantity allowed for purchase is %s.', ITwebexperts_Payperrentals_Helper_Inventory::getMaxSaleQuantity($product)))->setErrorCode('qty_max')->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in requested quantity.'))->setQuoteMessageIndex('qty');
             return $result;
         }
         $result->addData($this->checkQtyIncrements($qty)->getData());
         if ($result->getHasError()) {
             return $result;
         }
         $option = $quoteItem->getOptionByCode('info_buyRequest');
         $buyRequest = $option ? unserialize($option->getValue()) : null;
         if (Mage::app()->getStore()->isAdmin() && Mage::getSingleton('adminhtml/session_quote')->getOrderId()) {
             $editedOrderId = Mage::getSingleton('adminhtml/session_quote')->getOrderId();
             $order = Mage::getModel('sales/order')->load($editedOrderId);
             $buyRequestArray = (array) $buyRequest;
             foreach ($order->getAllItems() as $oItem) {
                 if ($oItem->getProduct()->getId() != $product->getId()) {
                     continue;
                 }
                 if (is_object($oItem->getOrderItem())) {
                     $item = $oItem->getOrderItem();
                 } else {
                     $item = $oItem;
                 }
                 if ($item->getParentItem()) {
                     continue;
                 }
                 //check for bundles
                 if (count($item->getChildrenItems()) > 0) {
                     foreach ($item->getChildrenItems() as $child) {
                         $turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($child->getProductId(), $child);
                         $buyRequestArray['excluded_qty'][] = array('product_id' => $child->getProductId(), 'start_date' => $turnoverArr['before'], 'end_date' => $turnoverArr['after'], 'qty' => $item->getQtyOrdered());
                     }
                 } else {
                     $turnoverArr = ITwebexperts_Payperrentals_Helper_Data::getTurnoverFromQuoteItemOrBuyRequest($item->getProductId(), $item);
                     $buyRequestArray['excluded_qty'][] = array('product_id' => $item->getProductId(), 'start_date' => $turnoverArr['before'], 'end_date' => $turnoverArr['after'], 'qty' => $item->getQtyOrdered());
                 }
             }
             $buyRequest = new Varien_Object($buyRequestArray);
         }
         if (isset($buyRequest['start_date']) && isset($buyRequest['end_date'])) {
             if (strtotime($buyRequest['start_date']) > strtotime($buyRequest['end_date'])) {
                 $message = Mage::helper('payperrentals')->__('Start Date is bigger then End Date. Please change!');
                 $result->setHasError(true)->setMessage($message)->setQuoteMessage($message);
                 return $result;
             }
         }
         $isAvailable = false;
         if (ITwebexperts_Payperrentals_Helper_Inventory::isAllowedOverbook($product->getId())) {
             $isAvailable = true;
         }
         if (ITwebexperts_Payperrentals_Helper_Data::isBuyout($buyRequest)) {
             if (!$isAvailable) {
                 Mage::register('quote_item_id', $quoteItemId);
                 $maxQty = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($product, null, null, $buyRequest);
                 Mage::unregister('quote_item_id');
                 if ($maxQty >= $qty) {
                     $isAvailable = true;
                 }
             }
             if ($isAvailable) {
                 return $result;
             } else {
                 $message = Mage::helper('payperrentals')->__('There is not enough quantity for buy this product');
                 $result->setHasError(true)->setMessage($message)->setQuoteMessage($message);
                 return $result;
             }
         }
         if (!Mage::app()->getStore()->isAdmin() && !Mage::getSingleton('checkout/session')->getIsExtendedQuote() && isset($buyRequest['start_date']) && isset($buyRequest['end_date']) && ITwebexperts_Payperrentals_Helper_Inventory::isExcludedDay($product->getId(), $buyRequest['start_date'], $buyRequest['end_date'])) {
             $message = Mage::helper('payperrentals')->__('There are blocked dates or excluded days on your selected dates!');
             $result->setHasError(true)->setMessage($message)->setQuoteMessage($message);
             return $result;
         } else {
             if (!$isAvailable && isset($buyRequest['start_date']) && isset($buyRequest['end_date'])) {
                 Mage::register('quote_item_id', $quoteItemId);
                 $maxQty = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($product, $startDate, $endDate, $buyRequest);
                 Mage::unregister('quote_item_id');
                 if ($maxQty >= $qty) {
                     $isAvailable = true;
                 }
             }
         }
         if (ITwebexperts_Payperrentals_Helper_Data::isUsingGlobalDatesShoppingCart($product) && !$buyRequest['start_date']) {
             $message = Mage::helper('payperrentals')->__('Please select Global Dates!');
             $result->setHasError(true)->setMessage($message)->setQuoteMessage($message);
             return $result;
         }
         if (!Mage::app()->getStore()->isAdmin() && !ITwebexperts_Payperrentals_Helper_Data::isBuyout($buyRequest) && (isset($buyRequest['start_date']) && strtotime($buyRequest['start_date']) < strtotime(date('Y-m-d')) || isset($buyRequest['end_date']) && strtotime($buyRequest['end_date']) < strtotime(date('Y-m-d')))) {
             $message = Mage::helper('payperrentals')->__('The selected Dates are in the past. Please select new dates!');
             $result->setHasError(true)->setMessage($message)->setQuoteMessage($message);
             return $result;
         }
         if (Mage::app()->getStore()->isAdmin() && ITwebexperts_Payperrentals_Helper_Inventory::isAllowedOverbook($product->getId()) && ITwebexperts_Payperrentals_Helper_Inventory::showAdminOverbookWarning()) {
             Mage::register('quote_item_id', $quoteItemId);
             $maxQty = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($product, $startDate, $endDate, $buyRequest, true);
             Mage::unregister('quote_item_id');
             if ($maxQty < $qty) {
                 $message = Mage::helper('cataloginventory')->__('Product is not available for the selected dates');
                 $result->setHasError(false)->setMessage($message)->setQuoteMessage($message)->setQuoteMessageIndex('qtyppr');
                 return $result;
             }
         }
         Mage::dispatchEvent('before_stock_check', array('buyrequest' => $buyRequest, 'isavailable' => &$isAvailable));
         if (!$isAvailable) {
             if (isset($buyRequest['start_date']) && isset($buyRequest['end_date'])) {
                 //Mage::register('no_quote', 1);
                 Mage::register('quote_item_id', $quoteItemId);
                 $maxQty = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($product, $startDate, $endDate, $buyRequest);
                 Mage::unregister('quote_item_id');
                 $maxQty = intval($maxQty / $qtyOption);
                 //Mage::unregister('no_quote', 1);
                 if ($maxQty > 0) {
                     $message = Mage::helper('payperrentals')->__('Max quantity available for these dates is: ' . $maxQty . ', your quantity has been adjusted.');
                     // Mage::getSingleton('checkout/session')->addError($message);
                     $result->setHasQtyOptionUpdate(true);
                     //$result->setOrigQty($maxQty);
                     $result->setQty($maxQty);
                     $result->setItemQty($maxQty);
                     $result->setMessage($message)->setQuoteMessage($message);
                     return $result;
                 }
                 $message = Mage::helper('cataloginventory')->__('The requested quantity for "%s" is not available.', $this->getProductName());
             } else {
                 $message = Mage::helper('cataloginventory')->__('Please select Start and End Dates');
             }
             $result->setHasError(true)->setMessage($message)->setQuoteMessage($message)->setQuoteMessageIndex('qtyppr');
             return $result;
         }
         return $result;
     }
     $return = parent::checkQuoteItemQty($qty, $summaryQty, $origQty);
     return $return;
 }
示例#21
0
 /**
  * Adding new item to quote
  *
  * @param   Mage_Sales_Model_Quote_Item $item
  * @return  Mage_Sales_Model_Quote
  */
 public function addItem(Mage_Sales_Model_Quote_Item $item)
 {
     $item->setQuote($this);
     if (!$item->getId()) {
         $this->getItemsCollection()->addItem($item);
         Mage::dispatchEvent('sales_quote_add_item', array('quote_item' => $item));
     }
     return $this;
 }
示例#22
0
 /**
  * Get item tax
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @return int
  */
 public function getItemGiftTax($item)
 {
     if ($item->getParentItemId()) {
         return 0;
     }
     $ratesData = $this->_getRates();
     $id = $item->getId();
     return isset($ratesData['gw_items'][$id]['amt']) ? $ratesData['gw_items'][$id]['amt'] : 0;
 }
示例#23
0
 /**
  * Set quote item
  *
  * @param   Mage_Sales_Model_Quote_Item $item
  * @return  Mage_Sales_Model_Quote_Item_Option
  */
 public function setItem($item)
 {
     $this->setItemId($item->getId());
     $this->_item = $item;
     return $this;
 }
示例#24
0
 /**
  * Returns the total accumulated catalog discounts on an item
  * @param Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Order_Item $item
  * @return int negative discount amount
  */
 protected function _getTotalItemCatalogDiscount($item)
 {
     if (!$item->getQuoteId() || !$item->getId()) {
         return 0;
     }
     $row_total_before_disc = $item->getRowTotalBeforeRedemptions();
     $row_total = $item->getRowTotal();
     if ($item->getRewardsCatalogDiscount()) {
         $total_discount = $item->getRewardsCatalogDiscount();
     } else {
         if (empty($row_total_before_disc)) {
             $item->setRowTotal($item->getRowTotalBeforeRedemptions());
             $item->setRowTotalInclTax($item->getRowTotalBeforeRedemptionsInclTax());
             $total_discount = $this->_getRedeemer()->getTotalCatalogDiscount($item);
         } else {
             $total_discount = $item->getRowTotalBeforeRedemptions() - $item->getRowTotal();
         }
     }
     return $total_discount;
 }