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


PHP Session::getQuote方法代码示例

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


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

示例1: _getDiscountAmount

 /**
  * Return mp discount
  *
  * @return float|int
  */
 protected function _getDiscountAmount()
 {
     $quote = $this->_checkoutSession->getQuote();
     $totals = $quote->getShippingAddress()->getTotals();
     $discount = isset($totals['discount_coupon']) ? $totals['discount_coupon']['value'] : 0;
     return $discount;
 }
开发者ID:SummaSolutions,项目名称:cart-magento2,代码行数:12,代码来源:FinanceCost.php

示例2: execute

 /**
  * Push trackEcommerceCartUpdate to tracker on cart view page
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return \Henhed\Piwik\Observer\CartViewObserver
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_dataHelper->isTrackingEnabled()) {
         $this->_trackerHelper->addQuote($this->_checkoutSession->getQuote(), $this->_piwikTracker);
     }
     return $this;
 }
开发者ID:henkelund,项目名称:magento2-henhed-piwik,代码行数:13,代码来源:CartViewObserver.php

示例3: getPaymentInfo

 /**
  * Retrieve payment info model
  *
  * @return \Magento\Payment\Model\Info|false
  */
 public function getPaymentInfo()
 {
     $info = $this->_checkoutSession->getQuote()->getPayment();
     if ($info->getMethod()) {
         return $info;
     }
     return false;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Info.php

示例4: _getQuoteItems

 /**
  * Returns an array of SKUs of items in the basket
  *
  * @return array
  */
 protected function _getQuoteItems()
 {
     $skus = [];
     foreach ($this->_checkoutSession->getQuote()->getAllVisibleItems() as $item) {
         $skus[] = $item->getProduct()->getData('sku');
     }
     return $skus;
 }
开发者ID:halk,项目名称:recowise-magento2-demo,代码行数:13,代码来源:Similar.php

示例5: afterGetConfig

 /**
  * @param \Magento\Checkout\Model\DefaultConfigProvider $subject
  * @param array $result
  * @return array
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterGetConfig(\Magento\Checkout\Model\DefaultConfigProvider $subject, array $result)
 {
     if ($this->persistentHelper->isEnabled() && $this->persistentSession->isPersistent() && !$this->customerSession->isLoggedIn()) {
         /** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */
         $quoteIdMask = $this->quoteIdMaskFactory->create();
         $result['quoteData']['entity_id'] = $quoteIdMask->load($this->checkoutSession->getQuote()->getId(), 'quote_id')->getMaskedId();
     }
     return $result;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:ConfigProviderPlugin.php

示例6: execute

 /**
  * Fetch coupon info
  *
  * Controller Action
  */
 public function execute()
 {
     $total = $this->getRequest()->getParam('cost');
     $quote = $this->_checkoutSession->getQuote();
     //save value to DiscountCoupon collect
     $this->_registry->register('mercadopago_total_amount', $total);
     $this->quoteRepository->save($quote->collectTotals());
     return;
 }
开发者ID:SummaSolutions,项目名称:cart-magento2,代码行数:14,代码来源:Subtotals.php

示例7: isQuoteSummaryValid

 /**
  *  Validates minimum quote amount and zero grand total
  *
  * @param bool $isInCatalog
  * @return bool
  */
 public function isQuoteSummaryValid($isInCatalog)
 {
     $quote = $isInCatalog ? null : $this->_checkoutSession->getQuote();
     // validate minimum quote amount and validate quote for zero grandtotal
     if (null !== $quote && (!$quote->validateMinimumAmount() || !$quote->getGrandTotal())) {
         return false;
     }
     return true;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:CheckoutValidator.php

示例8: execute

 /**
  * Dispatch request
  *
  * @return \Magento\Framework\Controller\ResultInterface
  * @throws Action\NotFoundException
  */
 public function execute()
 {
     $quote = $this->checkoutSession->getQuote();
     $address = $quote->getShippingAddress();
     $address->collectShippingRates()->save();
     $rates = $address->getGroupedAllShippingRates();
     $result = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_JSON);
     $result->setData($rates);
     return $result;
 }
开发者ID:nja78,项目名称:magento2,代码行数:16,代码来源:Index.php

示例9: __construct

 /**
  * @param \Magento\Framework\View\Element\Template\Context $context
  * @param \Magento\Checkout\Model\Session $checkoutSession
  * @param \Yireo\GoogleTagManager2\Helper\Data $helper
  * @param \Yireo\GoogleTagManager2\Model\Container $container
  * @param array $data
  */
 public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Checkout\Model\Session $checkoutSession, \Yireo\GoogleTagManager2\Helper\Data $helper, \Yireo\GoogleTagManager2\Model\Container $container, array $data = [])
 {
     $this->helper = $helper;
     $this->container = $container;
     $this->checkoutSession = $checkoutSession;
     $this->order = $this->checkoutSession->getLastRealOrder();
     $this->quote = $this->checkoutSession->getQuote();
     parent::__construct($context, $data);
     $this->storeManager = $this->_storeManager;
     $this->layout = $this->_layout;
 }
开发者ID:yireo,项目名称:Yireo_GoogleTagManager2,代码行数:18,代码来源:Generic.php

示例10: getReviewButtonTemplate

 /**
  * Get template for button in order review page if HSS method was selected
  *
  * @param string $name template name
  * @return string
  */
 public function getReviewButtonTemplate($name)
 {
     $quote = $this->_checkoutSession->getQuote();
     if ($quote) {
         $payment = $quote->getPayment();
         if ($payment && in_array($payment->getMethod(), $this->_hssMethods)) {
             return $name;
         }
     }
     return '';
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Hss.php

示例11: testCancelAction

 /**
  * @magentoDataFixture Magento/Paypal/_files/quote_payment_standard.php
  * @magentoConfigFixture current_store payment/paypal_standard/active 1
  * @magentoConfigFixture current_store paypal/general/business_account merchant_2012050718_biz@example.com
  */
 public function testCancelAction()
 {
     $quote = $this->_objectManager->create('Magento\\Sales\\Model\\Quote');
     $quote->load('test01', 'reserved_order_id');
     $this->_session->setQuoteId($quote->getId());
     $this->_session->setPaypalStandardQuoteId($quote->getId())->setLastRealOrderId('100000002');
     $this->dispatch('paypal/standard/cancel');
     $this->_order->load('100000002', 'increment_id');
     $this->assertEquals('canceled', $this->_order->getState());
     $this->assertEquals($this->_session->getQuote()->getGrandTotal(), $quote->getGrandTotal());
     $this->assertEquals($this->_session->getQuote()->getItemsCount(), $quote->getItemsCount());
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:StandardTest.php

示例12: afterGetSectionData

 /**
  * Add `trackEcommerceCartUpdate' checkout cart customer data
  *
  * @param \Magento\Checkout\CustomerData\Cart $subject
  * @param array $result
  * @return array
  */
 public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject, $result)
 {
     if ($this->_dataHelper->isTrackingEnabled()) {
         $quote = $this->_checkoutSession->getQuote();
         if ($quote->getId()) {
             $tracker = $this->_trackerFactory->create();
             $this->_trackerHelper->addQuote($quote, $tracker);
             $result['piwikActions'] = $tracker->toArray();
         }
     }
     return $result;
 }
开发者ID:henkelund,项目名称:magento2-henhed-piwik,代码行数:19,代码来源:CartPlugin.php

示例13: _toHtml

 /**
  * Check whether authentication is required and prepare some template data
  *
  * @return string
  */
 protected function _toHtml()
 {
     $method = $this->_checkoutSession->getQuote()->getPayment()->getMethodInstance();
     if ($method->getIsCentinelValidationEnabled()) {
         $centinel = $method->getCentinelValidator();
         if ($centinel && $centinel->shouldAuthenticate()) {
             $this->setAuthenticationStart(true);
             $this->setFrameUrl($centinel->getAuthenticationStartUrl());
             return parent::_toHtml();
         }
     }
     return parent::_toHtml();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:Authentication.php

示例14: execute

 /**
  * @return ResultInterface
  * @throws LocalizedException
  */
 public function execute()
 {
     $isAjax = $this->_request->getParam('isAjax');
     if (!$isAjax) {
         throw new LocalizedException(__('Wrong type of request.'));
     }
     $items = $this->checkoutSession->getQuote()->getAllItems();
     $response = ['isEmpty' => 0 === count($items), 'amount' => $this->checkoutSession->getQuote()->getBaseGrandTotal(), 'currency' => $this->checkoutSession->getQuote()->getCurrency()->getBaseCurrencyCode()];
     /** @var \Magento\Framework\Controller\Result\Json $resultJson */
     $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
     $resultJson->setData($response);
     return $resultJson;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:17,代码来源:GetButtonData.php

示例15: getConfig

 /**
  * @return array
  */
 public function getConfig()
 {
     $customFeeConfig = [];
     $enabled = $this->dataHelper->isModuleEnabled();
     $minimumOrderAmount = $this->dataHelper->getMinimumOrderAmount();
     $customFeeConfig['fee_label'] = $this->dataHelper->getFeeLabel();
     $quote = $this->checkoutSession->getQuote();
     $subtotal = $quote->getSubtotal();
     $customFeeConfig['custom_fee_amount'] = $this->dataHelper->getCustomFee();
     $customFeeConfig['show_hide_customfee_block'] = $enabled && $minimumOrderAmount <= $subtotal && $quote->getFee() ? true : false;
     $customFeeConfig['show_hide_customfee_shipblock'] = $enabled && $minimumOrderAmount <= $subtotal ? true : false;
     return $customFeeConfig;
 }
开发者ID:sivajik34,项目名称:Custom-Fee-Magento2,代码行数:16,代码来源:CustomFeeConfigProvider.php


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