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


PHP Mage_Sales_Model_Quote::getAllVisibleItems方法代码示例

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


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

示例1: doTransaction

 /**
  * Call Transaction API (Authorized & Capture at the same time)
  *
  * @param Eway_Rapid31_Model_Response $response
  * @return Eway_Rapid31_Model_Response
  */
 public function doTransaction(Eway_Rapid31_Model_Response $response)
 {
     $this->unsetData();
     $this->_buildRequest();
     $this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
     $items = $this->_quote->getAllVisibleItems();
     $lineItems = array();
     foreach ($items as $item) {
         /* @var Mage_Sales_Model_Order_Item $item */
         $lineItem = Mage::getModel('ewayrapid/field_lineItem');
         $lineItem->setSKU($item->getSku());
         $lineItem->setDescription(substr($item->getName(), 0, 26));
         $lineItem->setQuantity($item->getQty());
         $lineItem->setUnitCost(round($item->getBasePrice() * 100));
         $lineItem->setTax(round($item->getBaseTaxAmount() * 100));
         $lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
         $lineItems[] = $lineItem;
     }
     $this->setItems($lineItems);
     $this->setItems(false);
     // add Payment
     $amount = round($this->_quote->getBaseGrandTotal() * 100);
     $paymentParam = Mage::getModel('ewayrapid/field_payment');
     $paymentParam->setTotalAmount($amount);
     $paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
     $this->setPayment($paymentParam);
     $customerParam = $this->getCustomer();
     $customerParam->setTokenCustomerID($response->getTokenCustomerID());
     $this->setCustomer($customerParam);
     $response = $this->_doRapidAPI('Transaction');
     return $response;
 }
开发者ID:programmerrahul,项目名称:vastecom,代码行数:38,代码来源:Sharedpage.php

示例2: _updateQuote

 protected function _updateQuote(Mage_Sales_Model_Quote $quote)
 {
     if (!Mage::helper('recapture')->isEnabled()) {
         return $this;
     }
     if (!$quote->getId()) {
         return;
     }
     //sales_quote_save_before gets called like 5 times on some page loads, we don't want to do 5 updates per page load
     if (Mage::registry('recapture_has_posted')) {
         return;
     }
     Mage::register('recapture_has_posted', true);
     $mediaConfig = Mage::getModel('catalog/product_media_config');
     $storeId = Mage::app()->getStore();
     $transportData = array('first_name' => $quote->getCustomerFirstname(), 'last_name' => $quote->getCustomerLastname(), 'email' => $quote->getCustomerEmail(), 'external_id' => $quote->getId(), 'grand_total' => $quote->getGrandTotal(), 'products' => array(), 'totals' => array());
     $cartItems = $quote->getAllVisibleItems();
     foreach ($cartItems as $item) {
         $productModel = $item->getProduct();
         $productImage = (string) Mage::helper('catalog/image')->init($productModel, 'thumbnail');
         //check configurable first
         if ($item->getProductType() == 'configurable') {
             if (Mage::getStoreConfig('checkout/cart/configurable_product_image') == 'itself') {
                 $child = $productModel->getIdBySku($item->getSku());
                 $image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($child, 'thumbnail', $storeId);
                 if ($image) {
                     $productImage = $mediaConfig->getMediaUrl($image);
                 }
             }
         }
         //then check grouped
         if (Mage::getStoreConfig('checkout/cart/grouped_product_image') == 'parent') {
             $options = $productModel->getTypeInstance(true)->getOrderOptions($productModel);
             if (isset($options['super_product_config']) && $options['super_product_config']['product_type'] == 'grouped') {
                 $parent = $options['super_product_config']['product_id'];
                 $image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($parent, 'thumbnail', $storeId);
                 $productImage = $mediaConfig->getMediaUrl($image);
             }
         }
         $optionsHelper = Mage::helper('catalog/product_configuration');
         if ($item->getProductType() == 'configurable') {
             $visibleOptions = $optionsHelper->getConfigurableOptions($item);
         } else {
             $visibleOptions = $optionsHelper->getCustomOptions($item);
         }
         $product = array('name' => $item->getName(), 'sku' => $item->getSku(), 'price' => $item->getPrice(), 'qty' => $item->getQty(), 'image' => $productImage, 'options' => $visibleOptions);
         $transportData['products'][] = $product;
     }
     $totals = $quote->getTotals();
     foreach ($totals as $total) {
         //we pass grand total on the top level
         if ($total->getCode() == 'grand_total') {
             continue;
         }
         $total = array('name' => $total->getTitle(), 'amount' => $total->getValue());
         $transportData['totals'][] = $total;
     }
     Mage::helper('recapture/transport')->dispatch('cart', $transportData);
     return $this;
 }
开发者ID:recaptureio,项目名称:magento_connector,代码行数:60,代码来源:Observer.php

示例3: _deleteNominalItems

 /**
  * Get rid of all nominal items
  */
 protected function _deleteNominalItems()
 {
     foreach ($this->_quote->getAllVisibleItems() as $item) {
         if ($item->isNominal()) {
             $item->isDeleted(true);
         }
     }
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:11,代码来源:Quote.php

示例4: _extractQuoteSkuData

 /**
  * Get sku and qty data for a given quote
  * @param  Mage_Sales_Model_Quote $quote Quote object to extract data from
  * @return array                         Array of 'sku' => qty
  */
 protected function _extractQuoteSkuData(Mage_Sales_Model_Quote $quote)
 {
     $skuData = [];
     // use getAllVisibleItems to prevent dupes due to parent config + child used both being included
     foreach ($quote->getAllVisibleItems() as $item) {
         // before item's have been saved, getAllVisible items won't properly
         // filter child items...this extra check fixes it
         if ($item->getParentItem()) {
             continue;
         }
         $skuData[$item->getSku()] = ['item_id' => $item->getId(), 'managed' => Mage::helper('eb2ccore/quote_item')->isItemInventoried($item), 'virtual' => $item->getIsVirtual(), 'qty' => $item->getQty()];
     }
     return $skuData;
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:19,代码来源:Session.php

示例5: _validateQuote

 /**
  * Compare Magento quote and shopping cart details from the request
  *
  * @return bool
  */
 protected function _validateQuote()
 {
     $quoteItems = $this->_quote->getAllVisibleItems();
     $quoteItemsArray = array();
     $quoteItemsSku = array();
     /** @var $xmlItems SimpleXMLElement */
     $xmlItems = $this->_request->{$this->_orderNode}->items;
     $xmlItemsArray = array();
     $xmlItemsSku = array();
     foreach ($quoteItems as $item) {
         /** @var $item Mage_Sales_Model_Quote_Item */
         $quoteItemsArray[(string) $item->getSku()] = $item;
         $quoteItemsSku[] = (string) $item->getSku();
     }
     foreach ($xmlItems->children() as $item) {
         /** @var $item SimpleXMLElement */
         $xmlItemsArray[(string) $item->sku] = $item;
         $xmlItemsSku[] = (string) $item->sku;
     }
     $this->_debugData['quoteItemsSku'] = implode(', ', $quoteItemsSku);
     $this->_debugData['xmlItemsSku'] = implode(', ', $xmlItemsSku);
     // Validation of the shopping cart
     if (count($quoteItemsArray) != count($xmlItemsArray)) {
         $this->_debugData['reason'] = 'Quote validation failed: Qty of items';
         return false;
     }
     foreach ($quoteItemsArray as $sku => $item) {
         if (!isset($xmlItemsArray[$sku])) {
             $this->_debugData['reason'] = 'Quote validation failed: SKU doesn\'t exist';
             return false;
         }
         $xmlItem = $xmlItemsArray[$sku];
         $checkoutHelper = Mage::helper('checkout');
         if ($item->getQty() != (int) $xmlItem->qty || $checkoutHelper->getPriceInclTax($item) != Mage::app()->getStore()->roundPrice((double) $xmlItem->price)) {
             $this->_debugData['reason'] = 'Quote validation failed: Items don\'t match';
             return false;
         }
     }
     return true;
 }
开发者ID:rakuten-deutschland,项目名称:checkout-magento,代码行数:45,代码来源:Rope.php

示例6: getShoppingCartXML

 /**
  * Get Shopping Cart XML
  * @param Mage_Sales_Model_Quote $quote
  * @return string
  */
 public function getShoppingCartXML($quote)
 {
     $dom = new DOMDocument('1.0', 'utf-8');
     $ShoppingCart = $dom->createElement('ShoppingCart');
     $dom->appendChild($ShoppingCart);
     $ShoppingCart->appendChild($dom->createElement('CurrencyCode', $quote->getQuoteCurrencyCode()));
     $ShoppingCart->appendChild($dom->createElement('Subtotal', (int) (100 * $quote->getGrandTotal())));
     // Add Order Lines
     $items = $quote->getAllVisibleItems();
     /** @var $item Mage_Sales_Model_Quote_Item */
     foreach ($items as $item) {
         $product = $item->getProduct();
         $ShoppingCartItem = $dom->createElement('ShoppingCartItem');
         $ShoppingCartItem->appendChild($dom->createElement('Description', $item->getName()));
         $ShoppingCartItem->appendChild($dom->createElement('Quantity', (int) $item->getQty()));
         $ShoppingCartItem->appendChild($dom->createElement('Value', (int) bcmul($product->getFinalPrice(), 100)));
         $ShoppingCartItem->appendChild($dom->createElement('ImageURL', $product->getThumbnailUrl()));
         // NOTE: getThumbnailUrl is DEPRECATED!
         $ShoppingCart->appendChild($ShoppingCartItem);
     }
     return str_replace("\n", '', $dom->saveXML());
 }
开发者ID:AndreKlang,项目名称:Payex-Modules-Test,代码行数:27,代码来源:Order.php

示例7: _fillCartInformation

 /**
  * @param array $data
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
  */
 private function _fillCartInformation(&$data, $object)
 {
     $productIids = array();
     $productQtys = array();
     $productStyleIds = array();
     /** @var Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Order_Item $item */
     foreach ($object->getAllVisibleItems() as $item) {
         $productIids[] = $item->getProduct()->getIid();
         $productQtys[] = is_null($item->getQtyOrdered()) ? (int) $item->getQty() : (int) $item->getQtyOrdered();
         $productStyleIds[] = $item->getProduct()->getNumber() . '-' . $item->getProduct()->getColorCode();
     }
     $data['productStyleId'] = implode(',', $productStyleIds);
     $data['cartProductIds'] = implode(',', $productIids);
     $data['cartProductQtys'] = implode(',', $productQtys);
     $data['cartTotalNetto'] = round($object->getBaseSubtotal(), 2);
     $data['cartTotalBrutto'] = round($object->getBaseGrandTotal(), 2);
     $data['customerId'] = (int) $object->getCustomerId();
     // For zanox tracking
     if (array_key_exists('zanpid', $_COOKIE) && $_COOKIE['zanpid'] != '') {
         $data['zanpid'] = $_COOKIE['zanpid'];
     }
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:26,代码来源:Observer.php

示例8: isAllItemBackorderableAndOutOfStock

 /**
  * Return false if we have an item that's not backorderable or not out of stock
  * otherwise return true that all items are backorderable and out of stock.
  *
  * @param  Mage_Sales_Model_Quote
  * @return bool
  */
 protected function isAllItemBackorderableAndOutOfStock(Mage_Sales_Model_Quote $quote)
 {
     /** @var Mage_Sales_Model_Quote_Item[] $items */
     $items = $quote->getAllVisibleItems();
     foreach ($items as $item) {
         if ($this->quantityService->canSendInventoryAllocation($item)) {
             return false;
         }
     }
     return true;
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:18,代码来源:Service.php

示例9: isSingleQuote

 /**
  * @param Mage_Sales_Model_Quote $quote
  *
  * @return bool
  */
 protected function isSingleQuote($quote)
 {
     foreach ($quote->getAllVisibleItems() as $item) {
         if (($product = $item->getProduct()) && $product->getTypeId() === 'subscription') {
             return false;
         }
     }
     return true;
 }
开发者ID:edvanmacedo,项目名称:vindi-magento,代码行数:14,代码来源:Cc.php

示例10: prepareCollection

 /**
  * Convert the resource model collection to an array
  *
  * @param Mage_Sales_Model_Quote $quote
  *
  * @return array
  */
 public function prepareCollection(Mage_Sales_Model_Quote $quote)
 {
     // Store current state
     $actionType = $this->getActionType();
     $operation = $this->getOperation();
     // Change state
     $this->setActionType(self::ACTION_TYPE_COLLECTION);
     $this->setOperation(self::OPERATION_RETRIEVE);
     $data = [];
     $filter = $this->getFilter();
     foreach ($quote->getAllVisibleItems() as $item) {
         /** @var Mage_Sales_Model_Quote_Item $item */
         // Add data to result
         $data[$item->getId()] = $this->prepareItem($item, $filter);
     }
     // Restore old state
     $this->setActionType($actionType);
     $this->setOperation($operation);
     // This collection should always be a key/value hash and never a simple array
     $data = new ArrayObject($data);
     // Return prepared outbound data
     return $data;
 }
开发者ID:aoepeople,项目名称:aoe_cartapi,代码行数:30,代码来源:Item.php

示例11: handleAdminOrderException

 /**
  * Handle admin out of stock Exception thrown from ROM Inventory Service.
  *
  * @param  EbayEnterprise_Inventory_Exception_Quantity_Unavailable_Exception
  * @param  Mage_Sales_Model_Quote
  * @return self
  */
 protected function handleAdminOrderException(EbayEnterprise_Inventory_Exception_Quantity_Unavailable_Exception $e, Mage_Sales_Model_Quote $quote)
 {
     $this->getAdminQuoteSession()->addError($e->getMessage());
     foreach ($quote->getAllVisibleItems() as $quoteItem) {
         if (!$this->quantityService->isItemAvailable($quoteItem)) {
             $quote->deleteItem($quoteItem);
         }
     }
     return $this;
 }
开发者ID:ryaan-anthony,项目名称:magento-retail-order-management,代码行数:17,代码来源:Observer.php

示例12: updateQuoteTotalQty

 public function updateQuoteTotalQty(Mage_Sales_Model_Quote $quote)
 {
     $quote->setItemsCount(0);
     $quote->setItemsQty(0);
     $quote->setVirtualItemsQty(0);
     foreach ($quote->getAllVisibleItems() as $item) {
         if ($item->getParentItem()) {
             continue;
         }
         $children = $item->getChildren();
         if ($children && $item->isShipSeparately()) {
             foreach ($children as $child) {
                 if ($child->getProduct()->getIsVirtual()) {
                     $quote->setVirtualItemsQty($quote->getVirtualItemsQty() + $child->getQty() * $item->getQty());
                 }
             }
         }
         if ($item->getProduct()->getIsVirtual()) {
             $quote->setVirtualItemsQty($quote->getVirtualItemsQty() + $item->getQty());
         }
         $quote->setItemsCount($quote->getItemsCount() + 1);
         $quote->setItemsQty((double) $quote->getItemsQty() + $item->getQty());
     }
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:24,代码来源:Observer.php

示例13: isAllItemBackorderableAndOutOfStock

 /**
  * Return false if we have an item that's not backorderable or not out of stock
  * otherwise return true that all items are backorderable and out of stock.
  *
  * @param  Mage_Sales_Model_Quote
  * @return bool
  */
 protected function isAllItemBackorderableAndOutOfStock(Mage_Sales_Model_Quote $quote)
 {
     /** @var Mage_Sales_Model_Quote_Item[] $items */
     $items = $quote->getAllVisibleItems();
     foreach ($items as $item) {
         /** @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
         $stockItem = $item->getProduct()->getStockItem();
         if ($this->isAllocatable($stockItem)) {
             return false;
         }
     }
     return true;
 }
开发者ID:WinstonN,项目名称:magento-retail-order-management,代码行数:20,代码来源:Service.php

示例14: _addEcommerceItems

 /**
  * add all visible items from a quote as tracked ecommerce items
  * 
  * @param Fooman_Jirafe_Model_JirafeTracker $piwikTracker
  * @param Mage_Sales_Model_Quote $quote 
  */
 protected function _addEcommerceItems($piwikTracker, $quote)
 {
     foreach ($quote->getAllVisibleItems() as $item) {
         if ($item->getName()) {
             //we only want to track the main configurable item
             //but not the subitem
             if ($item->getParentItem()) {
                 if ($item->getParentItem()->getProductType() == 'configurable') {
                     continue;
                 }
             }
             $itemPrice = $item->getBasePrice();
             // This is inconsistent behaviour from Magento
             // base_price should be item price in base currency
             // TODO: add test so we don't get caught out when this is fixed in a future release
             if (!$itemPrice || $itemPrice < 1.0E-5) {
                 $itemPrice = $item->getPrice();
             }
             $piwikTracker->addEcommerceItem($item->getProduct()->getData('sku'), $item->getName(), Mage::helper('foomanjirafe')->getCategory($item->getProduct()), $itemPrice, $item->getQty());
         }
     }
 }
开发者ID:nhienvo,项目名称:magento-plugin,代码行数:28,代码来源:Observer.php

示例15: getItems

 /**
  * Returns all items from quote and validates
  * them by quantity and addresses.
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param ShopgateCart           $cart
  *
  * @return array
  */
 public function getItems($quote, ShopgateCart $cart)
 {
     $validator = Mage::getModel('shopgate/shopgate_cart_validation_stock');
     $items = array();
     $quote->collectTotals();
     /** @var Mage_Sales_Model_Quote_Item $_item */
     foreach ($quote->getAllVisibleItems() as $_item) {
         /** @var Mage_Catalog_Model_Product $_item */
         $items[] = $validator->validateStock($_item, $_item->getPriceInclTax(), $_item->getPrice());
     }
     foreach (Mage::helper('shopgate')->fetchMissingQuoteItems($cart, $quote) as $_item) {
         $item = Mage::helper('shopgate')->generateShopgateCartItem($_item->getProduct());
         $catchedErrors = $quote->getShopgateError();
         $sgError = ShopgateLibraryException::CART_ITEM_OUT_OF_STOCK;
         if ($catchedErrors) {
             if (array_key_exists($item->getItemNumber(), $catchedErrors)) {
                 foreach ($catchedErrors[$item->getItemNumber()] as $error) {
                     if ($error == Mage::helper('catalog')->__('The text is too long')) {
                         $sgError = ShopgateLibraryException::CART_ITEM_INPUT_VALIDATION_FAILED;
                     }
                 }
             }
         }
         $item->setError($sgError);
         $item->setErrorText(ShopgateLibraryException::getMessageFor($sgError));
         $items[] = $item;
     }
     return $items;
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:38,代码来源:Sales.php


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