diff --git a/Observer/CheckoutLayoutModifier.php b/Observer/CheckoutLayoutModifier.php index 6b7ab19..3396bc2 100644 --- a/Observer/CheckoutLayoutModifier.php +++ b/Observer/CheckoutLayoutModifier.php @@ -16,6 +16,21 @@ */ class CheckoutLayoutModifier implements ObserverInterface { + + /** + * @var \Magento\Checkout\Model\Session\Proxy + */ + protected $checkoutSession; + + /** + * @param \Magento\Checkout\Model\Session\Proxy $checkoutSession + */ + public function __construct( + \Magento\Checkout\Model\Session\Proxy $checkoutSession + ) { + $this->checkoutSession = $checkoutSession; + } + /** * @inheritDoc */ @@ -30,6 +45,14 @@ public function execute(Observer $observer) $originalElement = $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step'] ['children']['pickupInformation']['children']['shippingAdditional']; + if ($this->checkoutSession->getQuote() && $this->checkoutSession->getQuote()->getIsVirtual()) { + // Remove pickup for virtual quote and return + unset($jsLayout['components']['checkout']['children']['steps']['children']['shipping-step'] + ['children']['pickupInformation']); + + return; + } + $originalElement['component'] = 'MageWorx_PickupCheckout/js/view/checkout/select-store-container'; $originalElement['config']['template'] = 'MageWorx_PickupCheckout/checkout/select-store-container'; diff --git a/Plugin/AbstractAddDataToOrder.php b/Plugin/AbstractAddDataToOrder.php index 966d0d8..715bd9b 100644 --- a/Plugin/AbstractAddDataToOrder.php +++ b/Plugin/AbstractAddDataToOrder.php @@ -68,9 +68,15 @@ protected function out($entity) return true; } - $methodCode = $entity->getShippingAddress()->getShippingMethod(); + if ($entity->getIsVirtual()) { + return true; + } + + if ($entity->getShippingAddress()) { + $methodCode = $entity->getShippingAddress()->getShippingMethod(); + } - if (!$methodCode) { + if (empty($methodCode)) { $methodCode = $entity->getShippingMethod(); } diff --git a/composer.json b/composer.json index 3d088c9..ec6f7bb 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "mageworx/module-checkout": ">=1.0.0" }, "type": "magento2-module", - "version": "1.0.2", + "version": "1.0.3", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/view/frontend/web/template/checkout/container.html b/view/frontend/web/template/checkout/container.html index 1dc7e54..1cf85f2 100644 --- a/view/frontend/web/template/checkout/container.html +++ b/view/frontend/web/template/checkout/container.html @@ -46,7 +46,7 @@