Esempio n. 1
0
 /**
  * @param Mage_Sales_Model_Quote_Item $item
  * @return string
  */
 public function getItemEditOptionsHtml(Mage_Sales_Model_Quote_Item $item)
 {
     $product = $item->getProduct();
     $optionsBlock = $this->getLayout()->createBlock('emjainteractive_advancedoptions/catalog_product_view_options', 'product.info.options.' . $item->getId())->addOptionRenderer('file', 'emjainteractive_advancedoptions/catalog_product_view_options_type_text', 'emjainteractive/advancedoptions/catalog/product/view/options/type/text.phtml')->addOptionRenderer('select', 'emjainteractive_advancedoptions/catalog_product_view_options_type_select', 'emjainteractive/advancedoptions/catalog/product/view/options/type/select.phtml')->addOptionRenderer('date', 'emjainteractive_advancedoptions/catalog_product_view_options_type_date', 'emjainteractive/advancedoptions/catalog/product/view/options/type/date.phtml')->addOptionRenderer('text', 'emjainteractive_advancedoptions/catalog_product_view_options_type_text', 'emjainteractive/advancedoptions/catalog/product/view/options/type/text.phtml')->setTemplate('catalog/product/view/options.phtml')->setProduct($product)->setQuoteItem($item);
     $jsBlock = $this->getLayout()->createBlock('core/template', 'options_js' . $item->getId())->setTemplate('catalog/product/view/options/js.phtml');
     return $jsBlock->toHtml() . $optionsBlock->toHtml();
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 /**
  * Compare item
  *
  * @param   Mage_Sales_Model_Quote_Item $item
  * @return  bool
  */
 public function compare($item)
 {
     if ($item->getOptionByCode('chili_document_id')) {
         return false;
     }
     return parent::compare($item);
 }
 /**
  * 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;
 }
 /**
  * Get html for MAP product enabled
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @return string
  */
 public function getMsrpHtml($item)
 {
     $product = $item->getProduct();
     $block = $this->_preparePriceBlock($product);
     $html = $block->setPriceElementIdPrefix('bundle-price-')->toHtml();
     $product->setRealPriceHtml($html);
     return $this->_getPriceContent($product);
 }
Esempio n. 6
0
 /**
  * Get html for MAP product enabled
  *
  * @param Mage_Sales_Model_Quote_Item $item
  * @return string
  */
 public function getMsrpHtml($item)
 {
     $product = $item->getProduct();
     $block = $this->_preparePriceBlock($product);
     $html = $block->setDisplayMinimalPrice(true)->toHtml();
     $product->setRealPriceHtml($html);
     return $this->_getPriceContent($product);
 }
 /**
  * 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')) : '';
 }
Esempio n. 8
0
 /**
  * Set parent item
  *
  * @param  Mage_Sales_Model_Quote_Item $parentItem
  * @return Mage_Sales_Model_Quote_Item
  */
 public function setParentItem($parentItem)
 {
     if ($parentItem) {
         $this->_parentItem = $parentItem;
         $parentItem->addChild($this);
     }
     return $this;
 }
Esempio n. 9
0
 protected function setUp()
 {
     $this->_block = new Mage_Checkout_Block_Cart_Item_Renderer();
     $item = new Mage_Sales_Model_Quote_Item();
     $product = new Mage_Catalog_Model_Product();
     $product->load(1);
     $item->setProduct($product);
     $this->_block->setItem($item);
 }
Esempio n. 10
0
 public function quoteItemHasCustomTagOptions(Mage_Sales_Model_Quote_Item $quoteItem)
 {
     return array_reduce($quoteItem->getOptions(), function ($acc, Mage_Sales_Model_Quote_Item_Option $option) {
         if ($acc || !preg_match('/^option_/', $option->getCode())) {
             return $acc;
         }
         return !!Mage::getResourceModel('catalog/product_option_value_collection')->addFieldToFilter('option_type_id', $option->getValue())->addFieldToFilter('is_custom_tag', '1')->setPageSize(1)->load()->getSize();
     }, false);
 }
 /**
  * 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;
 }
Esempio n. 12
0
 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;
 }
Esempio n. 13
0
 /**
  * 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)
 {
     switch ($item->getProduct()->getTypeId()) {
         case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
             $model = Mage::getModel('shopgate/shopgate_cart_validation_stock_bundle');
             break;
         default:
             $model = Mage::getModel('shopgate/shopgate_cart_validation_stock_simple');
     }
     return $model->validateStock($item, $priceInclTax, $priceExclTax);
 }
Esempio n. 14
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();
 }
Esempio n. 15
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;
 }
Esempio n. 16
0
 public function testGetAddress()
 {
     $quote = $this->getMock('Mage_Sales_Model_Quote', array('getShippingAddress', 'getBillingAddress'), array(), '', false);
     $quote->expects($this->once())->method('getShippingAddress')->will($this->returnValue('shipping'));
     $quote->expects($this->once())->method('getBillingAddress')->will($this->returnValue('billing'));
     $this->_model->setQuote($quote);
     $quote->setItemsQty(2);
     $quote->setVirtualItemsQty(1);
     $this->assertEquals('shipping', $this->_model->getAddress(), 'Wrong shipping address');
     $quote->setItemsQty(2);
     $quote->setVirtualItemsQty(2);
     $this->assertEquals('billing', $this->_model->getAddress(), 'Wrong billing address');
 }
Esempio n. 17
0
 /**
  * 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());
 }
Esempio n. 18
0
 protected function _getPriceByItem(Mage_Sales_Model_Quote_Item $item)
 {
     $product = $item->getProduct();
     if (!$product->hasMtmPricelist() || $product->getMtmPricelist() == '') {
         return false;
     }
     $pricelist = $product->getAttributeText('mtm_pricelist');
     $helper = Mage::helper('catalog/product_configuration');
     $options = $helper->getCustomOptions($item);
     $options = array_column($options, 'value', 'option_type');
     $model = Mage::getModel("xxx_catalog/pricelist");
     $width = $options['width'];
     $height = $options['height'];
     $buyRequest = $product->getCustomOption('info_buyRequest')->getValue();
     $buyRequest = unserialize($buyRequest);
     $mtmParameters = [];
     foreach ($buyRequest as $key => $value) {
         if (strpos($key, 'mtm_') === 0) {
             $mtmParameters[] = $value;
         }
     }
     $price = 0;
     $price += $this->_getGraphicPrice($buyRequest);
     if (count($mtmParameters) > 0) {
         $paramsChain = implode('-', $mtmParameters);
         $price += $model->getPriceForSize($pricelist, $width, $height, $paramsChain);
         return $price;
     }
     // in case of wrong (incomplete) pricelist loaded by user, prevent setting product price to 0
     $price = $price > 0 ? $price : 999.99;
     return $price;
 }
 /**
  * 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;
 }
Esempio n. 20
0
 public function getProduct()
 {
     $product = parent::getProduct();
     if (!$product->getTypeId()) {
         $product->setTypeId('simple');
     }
     return $product;
 }
 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;
 }
 /**
  * Spawn the correct validator object and init it
  *
  * @param $rulesConfig array
  * @param Mage_Sales_Model_Quote_Item $item
  * @return Jarlssen_CustomCartValidation_Model_Factory
  */
 public function getRuleModels($rulesConfig, $item)
 {
     $ruleModels = array();
     $productType = $item->getProductType();
     foreach ($rulesConfig as $config) {
         if ('*' == $config['product_type'] || $config['product_type'] == $productType) {
             try {
                 $ruleModel = Mage::getModel($config['model']);
                 $ruleModel->setItem($item)->setCode($config['code'])->setOrigin($config['origin']);
                 $ruleModels[] = $ruleModel;
             } catch (Exception $e) {
                 Mage::logException($e);
             }
         }
     }
     return $ruleModels;
 }
 /**
  * Test if the item needs to have its quantity checked for available
  * inventory.
  * @param  Mage_Sales_Model_Quote_Item $item The item to check
  * @return bool True if inventory is managed, false if not
  */
 public function isItemInventoried(Mage_Sales_Model_Quote_Item $item)
 {
     // never consider a child product as inventoried, allow the parent deal
     // with inventory and let the child not need to worry about it as the parent
     // will be the item to keep track of qty being ordered.
     // Both checks needed as child items will not have a parent item id prior
     // to being saved and a parent item prior to being added to the parent (e.g.
     // immediately after being loaded from the DB).
     if ($item->getParentItemId() || $item->getParentItem()) {
         return false;
     }
     // when dealing with parent items, if any child of the product is managed
     // stock, consider the entire item as managed stock - allows for the parent
     // config product in the quote to deal with inventory while allowing child
     // products to not care individually
     if ($item->getHasChildren()) {
         foreach ($item->getChildren() as $childItem) {
             $childStock = $childItem->getProduct()->getStockItem();
             if ($this->isManagedStock($childStock)) {
                 // This Parent is inventoried. Child's ROM setting is 'No backorders', and Manage Stock check hasn't been manually overridden
                 return true;
             }
         }
         // if none of the children were managed stock, the parent is not inventoried
         return false;
     }
     return $this->isManagedStock($item->getProduct()->getStockItem());
 }
Esempio n. 24
0
 public function getMessage($string = true)
 {
     if ('checkout' == Mage::app()->getRequest()->getModuleName() && Mage::getStoreConfig('catalog/general/displayincart')) {
         $product = Mage::getModel('catalog/product')->load($this->getProduct()->getId());
         $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
         if (!Mage::getStoreConfig('catalog/general/displayforoutonly') || !$product->isSaleable() || $product->isInStock() && $stockItem->getData('qty') <= Mage::helper('amstockstatus')->getBackorderQnt()) {
             if (Mage::helper('amstockstatus')->getCustomStockStatusText($product)) {
                 $this->addMessage(Mage::helper('amstockstatus')->getCustomStockStatusText($product));
             }
         }
     }
     return parent::getMessage($string);
 }
Esempio n. 25
0
 public function compare($item)
 {
     //Get model for info_buyRequest option
     $option_model = $item->getOptionByCode('info_buyRequest');
     //Unserialize its value
     $options = unserialize($option_model->getValue());
     //Check if quote item represents web-to-print product.
     //If it does then do not merge these items.
     if (isset($options['zetaprints-TemplateID'])) {
         return false;
     }
     return parent::compare($item);
 }
Esempio n. 26
0
 protected function _getQtyByItem(Mage_Sales_Model_Quote_Item $item)
 {
     $item_list = $item->getData();
     $qty = $item_list['qty'];
     /*
     			$id=$item_list['product_id'];
     			$model=Mage::getModel('dailydeals/dailydeals');
     			
     			$collectiondeal=Mage::getModel('dailydeals/dailydeals')->getCollection()->addFieldToFilter('related_product',$id)->getData();
     			if(!empty($collectiondeal)){
     			$deal_qty=$collectiondeal[0]['deal_qty'];	
     			$deal_id=$collectiondeal[0]['dailydeals_id'];			
     			$remaining_qty=$deal_qty-$qty;
     			$deal_id=$collectiondeal[0]['dailydeals_id'];
     			$data['qty_sold']=$qty;
     			$data['remaining_qty']=$remaining_qty;			
     			$model->setData($data)->setId($deal_id);
     			$model->save();
     			return $remaining_qty;
     			}*/
     return $qty;
 }
Esempio n. 27
0
 /**
  * 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());
 }
Esempio n. 28
0
 public function representProduct($product)
 {
     if (parent::representProduct($product)) {
         $option = $product->getCustomOption('info_buyRequest');
         $productBuyRequest = new Varien_Object($option ? unserialize($option->getValue()) : null);
         $currentBuyRequest = $this->getBuyRequest();
         $productIsFree = isset($productBuyRequest['options']['ampromo_rule_id']) ? $productBuyRequest['options']['ampromo_rule_id'] : null;
         $currentIsFree = isset($currentBuyRequest['options']['ampromo_rule_id']) ? $currentBuyRequest['options']['ampromo_rule_id'] : null;
         return $productIsFree === $currentIsFree;
     } else {
         return false;
     }
 }
Esempio n. 29
0
 /**
  * Generate serialized product options as in POST or GET parameters
  * @param Mage_Sales_Model_Quote_Item $item
  * @return array
  */
 public function getProductOptionsParameters(Mage_Sales_Model_Quote_Item $item)
 {
     $product = $item->getProduct();
     $options = $this->getProductOptions($item);
     $data = array();
     foreach ($options as $option) {
         $id = $option['option_id'];
         $objOption = $product->getOptionById($id);
         $objValues = $objOption->getValuesCollection()->getItems();
         $value = $this->_mapValueToOptionValue($option['value'], $objValues);
         // overwrite multi-options
         if (in_array($option['option_type'], array('multiple', 'checkbox'))) {
             $values = array_filter(explode(', ', $value));
             $value = array();
             foreach ($values as $optionId) {
                 $value[] = $this->_mapValueToOptionValue($optionId, $objValues);
             }
         }
         // overwrite date-time options
         if (in_array($option['option_type'], array('date_time', 'date', 'time'))) {
             $timestamp = strtotime($value);
             $value = array();
             if (in_array($option['option_type'], array('date_time', 'date'))) {
                 $value['month'] = date('n', $timestamp);
                 $value['day'] = date('j', $timestamp);
                 $value['year'] = date('Y', $timestamp);
             }
             if (in_array($option['option_type'], array('date_time', 'time'))) {
                 $value['hour'] = date('g', $timestamp);
                 $value['minute'] = ltrim(date('i', $timestamp), '0');
                 $value['minute'] = $value['minute'] ? $value['minute'] : '0';
                 $value['day_part'] = date('a', $timestamp);
             }
         }
         $data[$id] = $value;
     }
     return $data;
 }
Esempio n. 30
0
 /**
  * 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;
 }