Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-sales
Observer
Frontend
RestoreCustomerGroupId.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Sales\Observer\Frontend
;
7
8
use
Magento\Customer\Helper\Address
as CustomerAddress;
9
use
Magento\Customer\Model\Address\AbstractAddress
;
10
use
Magento\Framework\Event\Observer
;
11
use
Magento\Framework\Event\ObserverInterface
;
12
use
Magento\Quote\Api\Data\ShippingAssignmentInterface
;
13
use
Magento\Quote\Model\Quote
;
14
18
class
RestoreCustomerGroupId
implements
ObserverInterface
19
{
25
protected
$customerAddressHelper
;
26
30
public
function
__construct
(CustomerAddress
$customerAddressHelper
)
31
{
32
$this->customerAddressHelper =
$customerAddressHelper
;
33
}
34
41
public
function
execute
(
Observer
$observer
)
42
{
44
$shippingAssignment =
$observer
->getEvent()->getShippingAssignment();
46
$quote
=
$observer
->getEvent()->getQuote();
47
48
$address
= $shippingAssignment->getShipping()->getAddress();
49
$configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType();
50
// Restore initial customer group ID in quote only if VAT is calculated based on shipping address
51
if
(
$address
->hasPrevQuoteCustomerGroupId() &&
52
$configAddressType ==
AbstractAddress::TYPE_SHIPPING
53
) {
54
$quote
->setCustomerGroupId(
$address
->getPrevQuoteCustomerGroupId());
55
$address
->unsPrevQuoteCustomerGroupId();
56
}
57
}
58
}
Magento\Sales\Observer\Frontend\RestoreCustomerGroupId\__construct
__construct(CustomerAddress $customerAddressHelper)
Definition:
RestoreCustomerGroupId.php:30
Magento\Customer\Model\Address\AbstractAddress\TYPE_SHIPPING
const TYPE_SHIPPING
Definition:
AbstractAddress.php:45
Magento\Customer\Helper\Address
Definition:
Address.php:21
Magento\Customer\Model\Address\AbstractAddress
Definition:
AbstractAddress.php:38
Magento\Sales\Observer\Frontend
Definition:
AddVatRequestParamsOrderComment.php:6
Magento\Framework\Event\ObserverInterface
Definition:
ObserverInterface.php:16
$quote
$quote
Definition:
paypal_quote.php:17
Magento\Quote\Api\Data\ShippingAssignmentInterface
Definition:
ShippingAssignmentInterface.php:14
Magento\Sales\Observer\Frontend\RestoreCustomerGroupId\$customerAddressHelper
$customerAddressHelper
Definition:
RestoreCustomerGroupId.php:25
$address
$address
Definition:
customer.php:38
Magento\Sales\Observer\Frontend\RestoreCustomerGroupId
Definition:
RestoreCustomerGroupId.php:18
$observer
$observer
Definition:
second_website_with_second_currency.php:38
Magento\Framework\Event\Observer
Definition:
Collection.php:12
Magento\Quote\Model\Quote
Definition:
AddressTest.php:6
Magento\Framework\Event\ObserverInterface\execute
execute(Observer $observer)
Magento\Framework\Event\Observer
Definition:
Observer.php:14