本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 '';
}
示例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());
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}