當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Observer::getQuote方法代碼示例

本文整理匯總了PHP中Magento\Framework\Event\Observer::getQuote方法的典型用法代碼示例。如果您正苦於以下問題:PHP Observer::getQuote方法的具體用法?PHP Observer::getQuote怎麽用?PHP Observer::getQuote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Event\Observer的用法示例。


在下文中一共展示了Observer::getQuote方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * Handle customer VAT number if needed on collect_totals_before event of quote address
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment */
     $shippingAssignment = $observer->getShippingAssignment();
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $observer->getQuote();
     /** @var \Magento\Quote\Model\Quote\Address $address */
     $address = $shippingAssignment->getShipping()->getAddress();
     $customer = $quote->getCustomer();
     $storeId = $customer->getStoreId();
     if ($customer->getDisableAutoGroupChange() || false == $this->vatValidator->isEnabled($address, $storeId)) {
         return;
     }
     $customerCountryCode = $address->getCountryId();
     $customerVatNumber = $address->getVatId();
     $groupId = null;
     if (empty($customerVatNumber) || false == $this->customerVat->isCountryInEU($customerCountryCode)) {
         $groupId = $customer->getId() ? $this->groupManagement->getDefaultGroup($storeId)->getId() : $this->groupManagement->getNotLoggedInGroup()->getId();
     } else {
         // Magento always has to emulate group even if customer uses default billing/shipping address
         $groupId = $this->customerVat->getCustomerGroupIdBasedOnVatNumber($customerCountryCode, $this->vatValidator->validate($address, $storeId), $storeId);
     }
     if ($groupId) {
         $address->setPrevQuoteCustomerGroupId($quote->getCustomerGroupId());
         $quote->setCustomerGroupId($groupId);
         $customer->setGroupId($groupId);
         $quote->setCustomer($customer);
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:35,代碼來源:CollectTotalsObserver.php

示例2: execute

 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $quote = $observer->getQuote();
     $this->_items = $quote->getAllItems();
     //   if (count($this->_items)>0){
     $this->setCartProductTaxAmount($quote);
     //  }
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:8,代碼來源:AdminVatExemptObserver.php

示例3: execute

 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     return;
     $payment = $observer->getQuote()->getPayment();
     $cc_bin = substr($payment->getCcNumber(), 0, 6);
     if ($cc_bin) {
         $payment->setAdditionalInformation('riskified_cc_bin', $cc_bin);
     }
 }
開發者ID:Riskified,項目名稱:magento2,代碼行數:9,代碼來源:CollectPaymentInfo.php

示例4: execute

 /**
  * Set payment fee to order
  *
  * @param EventObserver $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $quote = $observer->getQuote();
     $CustomFeeFee = $quote->getFee();
     $CustomFeeBaseFee = $quote->getBaseFee();
     if (!$CustomFeeFee || !$CustomFeeBaseFee) {
         return $this;
     }
     //Set fee data to order
     $order = $observer->getOrder();
     $order->setData('fee', $CustomFeeFee);
     $order->setData('base_fee', $CustomFeeBaseFee);
     return $this;
 }
開發者ID:sivajik34,項目名稱:Custom-Fee-Magento2,代碼行數:20,代碼來源:AddFeeToOrderObserver.php

示例5: execute

 /**
  * Add subtotals to order data
  *
  * @param EventObserver $observer
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     $order = $observer->getOrder();
     $quote = $observer->getQuote();
     $discountCoupon = $quote->getShippingAddress()->getDiscountCouponAmount();
     $baseDiscountCoupon = $quote->getShippingAddress()->getBaseDiscountCouponAmount();
     $financeCost = $quote->getShippingAddress()->getFinanceCostAmount();
     $baseFinanceCost = $quote->getShippingAddress()->getBaseFinanceCostAmount();
     if (!empty($discountCoupon)) {
         $order->setDiscountCouponAmount($discountCoupon);
         $order->setBaseDiscountCouponAmount($baseDiscountCoupon);
     }
     if (!empty($financeCost)) {
         $order->setFinanceCostAmount($financeCost);
         $order->setBaseFinanceCostAmount($baseFinanceCost);
     }
     return $this;
 }
開發者ID:SummaSolutions,項目名稱:cart-magento2,代碼行數:24,代碼來源:AddMpSubtotalsToOrderObserver.php


注:本文中的Magento\Framework\Event\Observer::getQuote方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。