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