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


PHP Mage_Sales_Model_Quote::collectTotals方法代码示例

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


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

示例1: _afterLoad

 protected function _afterLoad()
 {
     $productCollection = $this->_getProductCollection();
     $recollectQuote = false;
     foreach ($this as $item) {
         $product = $productCollection->getItemById($item->getProductId());
         if ($this->_quote) {
             $item->setQuote($this->_quote);
         }
         if (!$product) {
             $item->isDeleted(true);
             $recollectQuote = true;
             continue;
         }
         if ($item->getSuperProductId()) {
             $superProduct = $productCollection->getItemById($item->getSuperProductId());
         } else {
             $superProduct = null;
         }
         $itemProduct = clone $product;
         if ($superProduct) {
             $itemProduct->setSuperProduct($superProduct);
             $item->setSuperProduct($superProduct);
         }
         $item->importCatalogProduct($itemProduct);
         $item->checkData();
     }
     if ($recollectQuote && $this->_quote) {
         $this->_quote->collectTotals();
     }
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:32,代码来源:Collection.php

示例2: _assignProducts

 /**
  * Add products to items and item options
  *
  * @return Mage_Sales_Model_Mysql4_Quote_Item_Collection
  */
 protected function _assignProducts()
 {
     Varien_Profiler::start('QUOTE:' . __METHOD__);
     $productIds = array();
     foreach ($this as $item) {
         $productIds[] = $item->getProductId();
     }
     $this->_productIds = array_merge($this->_productIds, $productIds);
     $productCollection = Mage::getModel('catalog/product')->getCollection()->setStoreId($this->getStoreId())->addIdFilter($this->_productIds)->addAttributeToSelect(Mage::getSingleton('sales/quote_config')->getProductAttributes())->addOptionsToResult()->addStoreFilter()->addUrlRewrite();
     Mage::dispatchEvent('sales_quote_item_collection_products_after_load', array('product_collection' => $productCollection));
     $recollectQuote = false;
     foreach ($this as $item) {
         if ($product = $productCollection->getItemById($item->getProductId())) {
             $product->setCustomOptions(array());
             foreach ($item->getOptions() as $option) {
                 /**
                  * Call type specified logic for product associated with quote item
                  */
                 $product->getTypeInstance(true)->assignProductToOption($productCollection->getItemById($option->getProductId()), $option, $product);
             }
             $item->setProduct($product);
         } else {
             $item->isDeleted(true);
             $recollectQuote = true;
         }
         $item->checkData();
     }
     if ($recollectQuote && $this->_quote) {
         $this->_quote->collectTotals();
     }
     Varien_Profiler::stop('QUOTE:' . __METHOD__);
     return $this;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:38,代码来源:Collection.php

示例3: place

 /**
  * Place the order and recurring payment profiles when customer returned from paypal
  * Until this moment all quote data must be valid
  *
  * @param string $token
  * @param string $shippingMethodCode
  */
 public function place($token, $shippingMethodCode = null)
 {
     if ($shippingMethodCode) {
         $this->updateShippingMethod($shippingMethodCode);
     }
     $isNewCustomer = false;
     switch ($this->getCheckoutMethod()) {
         case Mage_Checkout_Model_Type_Onepage::METHOD_GUEST:
             $this->_prepareGuestQuote();
             break;
         case Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER:
             $this->_prepareNewCustomerQuote();
             $isNewCustomer = true;
             break;
         default:
             $this->_prepareCustomerQuote();
             break;
     }
     $this->_ignoreAddressValidation();
     $this->_quote->collectTotals();
     $parameters = array('quote' => $this->_quote);
     $service = Mage::getModel('Mage_Sales_Model_Service_Quote', $parameters);
     $service->submitAll();
     $this->_quote->save();
     if ($isNewCustomer) {
         try {
             $this->_involveNewCustomer();
         } catch (Exception $e) {
             Mage::logException($e);
         }
     }
     $this->_recurringPaymentProfiles = $service->getRecurringPaymentProfiles();
     // TODO: send recurring profile emails
     $order = $service->getOrder();
     if (!$order) {
         return;
     }
     $this->_billingAgreement = $order->getPayment()->getBillingAgreement();
     // commence redirecting to finish payment, if paypal requires it
     if ($order->getPayment()->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT)) {
         $this->_redirectUrl = $this->_config->getExpressCheckoutCompleteUrl($token);
     }
     switch ($order->getState()) {
         // even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
         case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
             // TODO
             break;
             // regular placement, when everything is ok
             // regular placement, when everything is ok
         // regular placement, when everything is ok
         // regular placement, when everything is ok
         case Mage_Sales_Model_Order::STATE_PROCESSING:
         case Mage_Sales_Model_Order::STATE_COMPLETE:
         case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
             $order->sendNewOrderEmail();
             break;
     }
     $this->_order = $order;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:66,代码来源:Checkout.php

示例4: _placeOrder

 protected function _placeOrder($checkoutMessage, $orderStatus = 'pending', $notifyCreateOrder = false)
 {
     $this->_quote->collectTotals();
     $this->_quote->reserveOrderId();
     error_reporting(E_ERROR);
     $service = Mage::getModel('sales/service_quote', $this->_quote);
     // If file not exist may catch warring
     error_reporting(E_ALL);
     if ($service != false && method_exists($service, 'submitAll')) {
         // Magento version 1.4.1.x
         //  $service = Mage::getModel('sales/service_quote', $quote);
         $service->submitAll();
         $orderObj = $service->getOrder();
     } else {
         // Magento version 1.4.0.x , 1.3.x
         $convertQuoteObj = Mage::getSingleton('sales/convert_quote');
         $orderObj = $convertQuoteObj->addressToOrder($this->_quote->getShippingAddress());
         $orderObj->setBillingAddress($convertQuoteObj->addressToOrderAddress($this->_quote->getBillingAddress()));
         $orderObj->setShippingAddress($convertQuoteObj->addressToOrderAddress($this->_quote->getShippingAddress()));
         $orderObj->setPayment($convertQuoteObj->paymentToOrderPayment($this->_quote->getPayment()));
         $items = $this->_quote->getShippingAddress()->getAllItems();
         foreach ($items as $item) {
             //@var $item Mage_Sales_Model_Quote_Item
             $orderItem = $convertQuoteObj->itemToOrderItem($item);
             if ($item->getParentItem()) {
                 $orderItem->setParentItem($orderObj->getItemByQuoteItemId($item->getParentItem()->getId()));
             }
             $orderObj->addItem($orderItem);
         }
         $orderObj->setCanShipPartiallyItem(false);
         $orderObj->place();
     }
     $orderMessages = '';
     $notifyMessages = $this->_processNotifyMessage();
     if ($checkoutMessage || $notifyMessages) {
         $orderMessages .= '<br /><b><u>' . Mage::helper('M2ePro')->__('M2E Pro Notes') . ':</u></b><br /><br />';
         if ($checkoutMessage) {
             $orderMessages .= '<b>' . Mage::helper('M2ePro')->__('Checkout Message From Buyer') . ':</b>';
             $orderMessages .= $checkoutMessage . '<br />';
         }
         if ($notifyMessages) {
             $orderMessages .= $notifyMessages;
         }
     }
     // Adding notification to order
     $orderObj->addStatusToHistory($orderStatus, $orderMessages, false);
     $orderObj->save();
     // --------------------
     Mage::helper('M2ePro/Module')->getConfig()->setGroupValue('/synchronization/orders/', 'current_magento_order_id', $orderObj->getId());
     $this->setFatalErrorHandler();
     // --------------------
     // Send Notification to customer after create order
     if ($notifyCreateOrder) {
         // Send new order E-mail only if select such mode
         $orderObj->sendNewOrderEmail();
     }
     return $orderObj;
 }
开发者ID:par-orillonsoft,项目名称:app,代码行数:58,代码来源:Order.php

示例5: updateShippingMethod

 /**
  * Set shipping method to quote, if needed
  * @param string $methodCode
  */
 public function updateShippingMethod($methodCode)
 {
     if (!$this->_quote->getIsVirtual() && ($shippingAddress = $this->_quote->getShippingAddress())) {
         if ($methodCode != $shippingAddress->getShippingMethod()) {
             $this->_ignoreAddressValidation();
             $shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
             $this->_quote->collectTotals()->save();
         }
     }
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:14,代码来源:Checkout.php

示例6: _afterLoad

 protected function _afterLoad()
 {
     if (VPROF) {
         Varien_Profiler::start('TEST1: ' . __METHOD__);
     }
     $productCollection = $this->_getProductCollection();
     if (VPROF) {
         Varien_Profiler::stop('TEST1: ' . __METHOD__);
     }
     $recollectQuote = false;
     foreach ($this as $item) {
         if (VPROF) {
             Varien_Profiler::start('TEST2: ' . __METHOD__);
         }
         if ($productCollection) {
             $product = $productCollection->getItemById($item->getProductId());
         } else {
             $product = false;
         }
         if ($this->_quote) {
             $item->setQuote($this->_quote);
         }
         if (!$product) {
             $item->isDeleted(true);
             $recollectQuote = true;
             continue;
         }
         if ($item->getSuperProductId()) {
             $superProduct = $productCollection->getItemById($item->getSuperProductId());
             if (!$superProduct) {
                 $item->isDeleted(true);
                 $recollectQuote = true;
                 continue;
             }
         } else {
             $superProduct = null;
         }
         $itemProduct = clone $product;
         if ($superProduct) {
             $itemProduct->setSuperProduct($superProduct);
             $item->setSuperProduct($superProduct);
         }
         $item->importCatalogProduct($itemProduct);
         $item->checkData();
         if (VPROF) {
             Varien_Profiler::stop('TEST2: ' . __METHOD__);
         }
     }
     if ($recollectQuote && $this->_quote) {
         $this->_quote->collectTotals();
     }
     return $this;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:53,代码来源:Entity_Quote_Item_Collection.php

示例7: testCollectTotalsWithVirtual

 /**
  * @magentoDataFixture Mage/Catalog/_files/product_virtual.php
  * @magentoDataFixture Mage/Sales/_files/quote.php
  */
 public function testCollectTotalsWithVirtual()
 {
     $quote = new Mage_Sales_Model_Quote();
     $quote->load('test01', 'reserved_order_id');
     $product = new Mage_Catalog_Model_Product();
     $product->load(21);
     $quote->addProduct($product);
     $quote->collectTotals();
     $this->assertEquals(2, $quote->getItemsQty());
     $this->assertEquals(1, $quote->getVirtualItemsQty());
     $this->assertEquals(20, $quote->getGrandTotal());
     $this->assertEquals(20, $quote->getBaseGrandTotal());
 }
开发者ID:nemphys,项目名称:magento2,代码行数:17,代码来源:QuoteTest.php

示例8: buildQuote

 /**
  * Build quote object
  *
  * @throws Exception
  */
 public function buildQuote()
 {
     try {
         // do not change invoke order
         // --------------------
         $this->initializeQuote();
         $this->initializeCustomer();
         $this->initializeAddresses();
         $this->configureStore();
         $this->initializeCurrency();
         $this->initializeShippingMethodData();
         $this->initializeQuoteItems();
         $this->initializePaymentMethodData();
         //$this->quote->setTotalsCollectedFlag(false);
         $this->quote->collectTotals()->save();
         $this->quote->reserveOrderId();
         // --------------------
     } catch (Exception $e) {
         $this->quote->setIsActive(false)->save();
         throw $e;
     }
 }
开发者ID:xiaoguizhidao,项目名称:beut,代码行数:27,代码来源:Quote.php

示例9: place

 /**
  * Place the order and recurring payment profiles when customer returned from paypal
  * Until this moment all quote data must be valid
  *
  * @param string $token
  * @param string $shippingMethodCode
  */
 public function place($token, $shippingMethodCode = null)
 {
     $this->updateShippingMethod($shippingMethodCode);
     $isNewCustomer = $this->_prepareQuote();
     $this->_ignoreAddressValidation();
     $this->_quote->collectTotals();
     $this->_getApi();
     $payerId = $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_PAYER_ID);
     $doExpressReply = $this->_api->doExpressCheckout($this->_quote, $token, $payerId);
     $doAuthorizationReply = $this->_api->doAuthorization($this->_quote);
     $this->_quote->getPayment()->importData(array_merge($doExpressReply, $doAuthorizationReply));
     $service = Mage::getModel('sales/service_quote', $this->_quote);
     try {
         $service->submitAll();
         // Any exceptions thrown from submitAll indicate an order that failed
         // to be created. In any such cases, the payment auth needs to be voided.
     } catch (Exception $e) {
         $this->_api->doVoidQuote($this->_quote);
         // Throw an exception for the controller to handle. Needs to indicate
         // the failure to complete the PayPal payment as the PayPal process
         // needs to be restarted once the auth was performed.
         throw Mage::exception('EbayEnterprise_PayPal', $this->_helper->__(EbayEnterprise_Paypal_Model_Express_Api::EBAYENTERPRISE_PAYPAL_API_FAILED));
     }
     $this->_quote->save();
     if ($isNewCustomer) {
         try {
             $this->_involveNewCustomer();
         } catch (Exception $e) {
             $this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e));
         }
     }
     $order = $service->getOrder();
     if (!$order) {
         return;
     }
     switch ($order->getState()) {
         // Even after placement, paypal can disallow authorize/capture
         case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
             break;
             // regular placement, when everything is ok
         // regular placement, when everything is ok
         case Mage_Sales_Model_Order::STATE_PROCESSING:
         case Mage_Sales_Model_Order::STATE_COMPLETE:
         case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
             $order->sendNewOrderEmail();
             break;
     }
     $this->_order = $order;
     Mage::dispatchEvent('checkout_submit_all_after', array('order' => $order, 'quote' => $this->_quote));
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:57,代码来源:Checkout.php

示例10: _assignProducts

 /**
  * Add products to items and item options
  *
  * @return Mage_Sales_Model_Resource_Quote_Item_Collection
  */
 protected function _assignProducts()
 {
     Magento_Profiler::start('QUOTE:' . __METHOD__);
     $productIds = array();
     foreach ($this as $item) {
         $productIds[] = (int) $item->getProductId();
     }
     $this->_productIds = array_merge($this->_productIds, $productIds);
     $productCollection = Mage::getModel('Mage_Catalog_Model_Product')->getCollection()->setStoreId($this->getStoreId())->addIdFilter($this->_productIds)->addAttributeToSelect(Mage::getSingleton('Mage_Sales_Model_Quote_Config')->getProductAttributes())->addOptionsToResult()->addStoreFilter()->addUrlRewrite()->addTierPriceData();
     Mage::dispatchEvent('prepare_catalog_product_collection_prices', array('collection' => $productCollection, 'store_id' => $this->getStoreId()));
     Mage::dispatchEvent('sales_quote_item_collection_products_after_load', array('product_collection' => $productCollection));
     $recollectQuote = false;
     foreach ($this as $item) {
         $product = $productCollection->getItemById($item->getProductId());
         if ($product) {
             $product->setCustomOptions(array());
             $qtyOptions = array();
             $optionProductIds = array();
             foreach ($item->getOptions() as $option) {
                 /**
                  * Call type specified logic for product associated with quote item
                  */
                 $product->getTypeInstance()->assignProductToOption($productCollection->getItemById($option->getProductId()), $option, $product);
                 if (is_object($option->getProduct()) && $option->getProduct()->getId() != $product->getId()) {
                     $optionProductIds[$option->getProduct()->getId()] = $option->getProduct()->getId();
                 }
             }
             if ($optionProductIds) {
                 foreach ($optionProductIds as $optionProductId) {
                     $qtyOption = $item->getOptionByCode('product_qty_' . $optionProductId);
                     if ($qtyOption) {
                         $qtyOptions[$optionProductId] = $qtyOption;
                     }
                 }
             }
             $item->setQtyOptions($qtyOptions);
             $item->setProduct($product);
         } else {
             $item->isDeleted(true);
             $recollectQuote = true;
         }
         $item->checkData();
     }
     if ($recollectQuote && $this->_quote) {
         $this->_quote->collectTotals();
     }
     Magento_Profiler::stop('QUOTE:' . __METHOD__);
     return $this;
 }
开发者ID:relue,项目名称:magento2,代码行数:54,代码来源:Collection.php

示例11: collectTotals

 /**
  * Collect totals patched for magento issue #26145
  *
  * @return Mage_Sales_Model_Quote
  */
 public function collectTotals()
 {
     /**
      * patch for magento issue #26145
      */
     if (!$this->getTotalsCollectedFlag()) {
         $items = $this->getAllItems();
         foreach ($items as $item) {
             $item->setData('calculation_price', null);
             $item->setData('original_price', null);
         }
     }
     parent::collectTotals();
     return $this;
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:20,代码来源:Quote.php

示例12: savePayment

 /**
  * Specify quote payment method
  *
  * @param array $data
  * @return array
  */
 public function savePayment($data)
 {
     if ($this->_quote->isVirtual()) {
         $this->_quote->getBillingAddress()->setPaymentMethod($this->_methodType);
     } else {
         $this->_quote->getShippingAddress()->setPaymentMethod($this->_methodType);
     }
     $payment = $this->_quote->getPayment();
     $data['method'] = $this->_methodType;
     $payment->importData($data);
     $email = isset($data['payer']) ? $data['payer'] : null;
     $payment->setAdditionalInformation(self::PAYMENT_INFO_PAYER_EMAIL, $email);
     $payment->setAdditionalInformation(self::PAYMENT_INFO_TRANSACTION_ID, isset($data['transaction_id']) ? $data['transaction_id'] : null);
     $this->_quote->setCustomerEmail($email);
     $this->_quote->collectTotals()->save();
     return array();
 }
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:23,代码来源:Checkout.php

示例13: updateAction

 /**
  * 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;
 }
开发者ID:relue,项目名称:magento2,代码行数:23,代码来源:CartController.php

示例14: place

 /**
  * Place the order and recurring payment profiles when customer returned from paypal
  * Until this moment all quote data must be valid
  *
  * @param string $token
  * @param string $shippingMethodCode
  */
 public function place($token, $shippingMethodCode = null)
 {
     $this->updateShippingMethod($shippingMethodCode);
     $isNewCustomer = $this->_prepareQuote();
     $this->_ignoreAddressValidation();
     $this->_quote->collectTotals();
     $this->_getApi();
     $payerId = $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_PAYER_ID);
     $doExpressReply = $this->_api->doExpressCheckout($this->_quote, $token, $payerId);
     $doAuthorizationReply = $this->_api->doAuthorization($this->_quote);
     $this->_quote->getPayment()->importData(array_merge($doExpressReply, $doAuthorizationReply));
     $service = Mage::getModel('sales/service_quote', $this->_quote);
     $service->submitAll();
     $this->_quote->save();
     if ($isNewCustomer) {
         try {
             $this->_involveNewCustomer();
         } catch (Exception $e) {
             $this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e));
         }
     }
     $order = $service->getOrder();
     if (!$order) {
         return;
     }
     switch ($order->getState()) {
         // Even after placement, paypal can disallow authorize/capture
         case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
             break;
             // regular placement, when everything is ok
         // regular placement, when everything is ok
         case Mage_Sales_Model_Order::STATE_PROCESSING:
         case Mage_Sales_Model_Order::STATE_COMPLETE:
         case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
             $order->sendNewOrderEmail();
             break;
     }
     $this->_order = $order;
     Mage::dispatchEvent('checkout_submit_all_after', array('order' => $order, 'quote' => $this->_quote));
 }
开发者ID:adderall,项目名称:magento-retail-order-management,代码行数:47,代码来源:Checkout.php

示例15: render

 public function render()
 {
     $customer = $this->_getCustomer();
     $this->_quote->setStore($this->_getStore())->setCustomer($customer);
     $this->_quote->getBillingAddress()->importCustomerAddress($customer->getDefaultBillingAddress());
     $this->_quote->getShippingAddress()->importCustomerAddress($customer->getDefaultShippingAddress());
     $productCount = rand(3, 10);
     for ($i = 0; $i < $productCount; $i++) {
         $product = $this->_getRandomProduct();
         if ($product) {
             $product->setQuoteQty(1);
             $this->_quote->addCatalogProduct($product);
         }
     }
     $this->_quote->getPayment()->setMethod('checkmo');
     $this->_quote->getShippingAddress()->setShippingMethod('freeshipping_freeshipping');
     //->collectTotals()->save();
     $this->_quote->getShippingAddress()->setCollectShippingRates(true);
     $this->_quote->collectTotals()->save();
     $this->_quote->save();
     return $this;
 }
开发者ID:hirentricore,项目名称:devmagento,代码行数:22,代码来源:Random.php


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