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


PHP Mage_Sales_Model_Quote::getTotals方法代码示例

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


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

示例1: _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

示例2: getTotals

 /**
  * Get all quote totals
  *
  * We need to remove a sisow_tax line that is created from
  * one of our models. Otherwise there will be two tax lines in the
  * checkout
  *
  * @return array
  */
 public function getTotals()
 {
     $totals = parent::getTotals();
     unset($totals['sisow_tax']);
     $totalsIndex = array_keys($totals);
     if (array_search('sisow_fee', $totalsIndex) === false) {
         return $totals;
     }
     unset($totalsIndex[array_search('sisow_fee', $totalsIndex)]);
     $fee = $totals['sisow_fee'];
     unset($totals['sisow_fee']);
     $feeIndex = array_search('shipping', $totalsIndex);
     if ($feeIndex === false) {
         $feeIndex = array_search('subtotal', $totalsIndex) + 1;
     }
     $sortedTotals = array();
     $size = count($totalsIndex);
     for ($i = 0; $i < $size; $i++) {
         if ($i == $feeIndex) {
             $sortedTotals['sisow_fee'] = $fee;
         }
         $sortedTotals[array_shift($totalsIndex)] = array_shift($totals);
     }
     return $sortedTotals;
 }
开发者ID:wouter90,项目名称:sisowpayment,代码行数:34,代码来源:Quote.php

示例3: getTotal

 /**
  * Get the specified total amount for the quote.
  *
  * @param  string
  * @param  Mage_Sales_Model_Quote
  * @return float
  */
 protected function getTotal($type, Mage_Sales_Model_Quote $quote)
 {
     $totals = $quote->getTotals();
     return isset($totals[$type]) ? $totals[$type]->getValue() : 0.0;
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:12,代码来源:Api.php

示例4: addTotal

 /**
  * @param \Vbw\Procurement\Punchout\Order $poOrder
  * @param Mage_Sales_Model_Quote $quote
  */
 public function addTotal($poOrder, $quote)
 {
     $configHelper = Mage::helper('vbw_punchout/config');
     /**@var $dataHelper Vbw_Punchout_Helper_Data*/
     $dataHelper = Mage::helper('vbw_punchout/data');
     /** @var $body \Vbw\Procurement\Punchout\Order\Body */
     $body = $poOrder->getBody();
     $totals = $quote->getTotals();
     $total = $quote->getSubtotal();
     if ($configHelper->getconfig('order/include_discount')) {
         if (isset($totals['discount'])) {
             $shippingTotal = $totals['discount']->getValue();
             $total += $shippingTotal;
         }
     }
     if ($configHelper->getconfig('order/include_shipping')) {
         if (isset($totals['shipping'])) {
             $shippingTotal = $totals['shipping']->getValue();
             $total += $shippingTotal;
         }
     }
     if ($configHelper->getconfig('order/include_tax')) {
         if (isset($totals['tax'])) {
             $taxTotal = $totals['tax']->getValue();
             $total += $taxTotal;
         }
     }
     $body->setTotal($dataHelper->getAsStoreCurrency($total));
 }
开发者ID:Eximagen,项目名称:pfizer,代码行数:33,代码来源:Distiller.php

示例5: _filterQuote

 /**
  * @param Mage_Sales_Model_Quote $quote
  *
  * @return Bronto_Common_Model_Email_Template_Filter
  */
 protected function _filterQuote(Mage_Sales_Model_Quote $quote)
 {
     if (!in_array('quote', $this->_filteredObjects)) {
         $this->setStoreId($quote->getStoreId());
         $currencyCode = $quote->getQuoteCurrencyCode();
         if (Mage::helper('bronto_common')->displayPriceIncTax($quote->getStoreId())) {
             $totals = $quote->getTotals();
             $this->setField('subtotal', $this->formatPrice($totals['subtotal']->getValue(), $currencyCode));
             $this->setField('grandTotal', $this->formatPrice($totals['grand_total']->getValue(), $currencyCode));
         } else {
             $this->setField('subtotal', $this->formatPrice($quote->getSubtotal(), $currencyCode));
             $this->setField('grandTotal', $this->formatPrice($quote->getGrandTotal(), $currencyCode));
         }
         $index = 1;
         foreach ($quote->getAllItems() as $item) {
             if (!$item->getParentItem()) {
                 $this->_filterQuoteItem($item, $index);
                 $index++;
             }
         }
         // Add Related Content
         $this->_items = $quote->getAllItems();
         $queryParams = $this->getQueryParams();
         $queryParams['id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($quote->getId())));
         if ($store = $this->getStore()) {
             $this->setField('quoteURL', $store->getUrl('reminder/load/index', $queryParams));
         } else {
             $this->setField('quoteURL', Mage::getUrl('reminder/load/index', $queryParams));
         }
         // Setup quote items as a template
         if (class_exists('Bronto_Reminder_Block_Cart_Items', false)) {
             $layout = Mage::getSingleton('core/layout');
             /* @var $items Mage_Sales_Block_Items_Abstract */
             $items = $layout->createBlock('bronto/bronto_reminder_cart_items', 'items');
             $items->setTemplate('bronto/reminder/items.phtml');
             $items->setQuote($item->getQuote());
             $this->_respectDesignTheme();
             $this->setField("cartItems", $items->toHtml());
         }
         $this->_filteredObjects[] = 'quote';
     }
     return $this;
 }
开发者ID:bevello,项目名称:bevello,代码行数:48,代码来源:Filter.php

示例6: buildAmount

 /**
  * Build Amount
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return Amount
  */
 protected function buildAmount($quote)
 {
     $details = new Details();
     $details->setShipping($quote->getShippingAddress()->getBaseShippingAmount())->setTax($quote->getBillingAddress()->getBaseTaxAmount() + $quote->getBillingAddress()->getBaseHiddenTaxAmount() + $quote->getShippingAddress()->getBaseTaxAmount() + $quote->getShippingAddress()->getBaseHiddenTaxAmount())->setSubtotal($quote->getBaseSubtotal());
     $totals = $quote->getTotals();
     if (isset($totals['discount']) && $totals['discount']->getValue()) {
         $details->setShippingDiscount(-$totals['discount']->getValue());
     }
     $amount = new Amount();
     $amount->setCurrency($quote->getBaseCurrencyCode())->setDetails($details)->setTotal($quote->getBaseGrandTotal());
     return $amount;
 }
开发者ID:kirchbergerknorr,项目名称:iways_paypalplus,代码行数:18,代码来源:Api.php


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