How to Skip Shipping Address Step During Checkout in Magento 2

checkoutmagento2shipping-address

In case of virtual products, we do not need a shipping step so customer directly goes for payment step during checkout.

I have a simple product and a custom field delivery_type in quote table. delivery_type field's value is updated on the cart page by selecting what is the delivery type (home/store).

If the value of delivery_type is store shipping step is not required and the customer should see only payment step similar to virtual products at checkout. Can anyone guide me on how I should go about customizing it?

I tried changing the value of field is_virtual to 1 in quote and quote_item table manually but it does not make any difference. I have logged window.checkoutConfig.quoteData.is_virtual which still shows 0.

Best Answer

Please have a look at this class

Magento\Quote\Model\Quote

in this class you have this method isVirtual() [image attached]

if the return result is true, Magento will skip the Shipping Step.

You can override this method or create a "after plugin" (recommended) to change the return value as you want

https://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html

enter image description here

Related Topic