1

All customers have a settled default shipping address so right now the shipment step is a bit redundant, how can I jump this step in Magento 2?

I managed to alter vendor\magento\module-checkout\view\frontend\templates\onepage\link.phtml (For test only) to then add:

<?php if ($block->isPossibleOnepageCheckout()):?>
    <button type="button"
            data-role="proceed-to-checkout"
            title="<?php /* @escapeNotVerified */ echo __('Proceed to Checkout') ?>"
            data-mage-init='{"Magento_Checkout/js/proceed-to-checkout":{"checkoutUrl":"<?php /* @escapeNotVerified */ echo $block->getCheckoutUrl().'#payment'; ?>"}}'
            class="action primary checkout<?php echo($block->isDisabled()) ? ' disabled' : ''; ?>"
            <?php if ($block->isDisabled()):?>disabled="disabled"<?php endif; ?>>
        <span><?php /* @escapeNotVerified */ echo __('Proceed to Checkout') ?></span>
    </button>
<?php endif?>

Notice the #payment anchor in:

data-mage-init='{"Magento_Checkout/js/proceed-to-checkout":{"checkoutUrl":"<?php /* @escapeNotVerified */ echo $block->getCheckoutUrl().'#payment'; ?>"}}'

The checkout goes through, it takes me directly to review and payment (final step) step but when click on the checkout button to finalize the order an error message appears saying that a shipment method has not been established

If a go back 1 step I can see the shipment address loaded

Magento is 2.1.1

2

normally, when you click the "next" button in the shipping step, an ajax call is triggered which sets the shipping address and shipping method in the quote.

If you want to skip this step you would have to trigger this ajax call before completing the order (or set the shipping method and address).

I think the easiest way would be to have a plugin before the PaymentInformationManagement::savePaymentInformationAndPlaceOrder() method which is triggered when you press the place order button in the checkout.

You need a seconde Plugin for guests on GuestPaymentInformationManagement::savePaymentInformationAndPlaceOrder()

In this plugin, you can then just set the default shipping address and shipping method on the quote object for the customer. ShippingInformationManagement::saveAddressInformation()

Or for guests: GuestShippingInformationManagement::saveAddressInformation()

  • Will try that. Guests are not allowed to checkout. I thought to add a js in the shipment step to autosubmit the shipment button (Given the case that the customer have a default address and no more and there is only 1 shipment method) but i like your idea better, thanks – Gianni Di Falco Sep 5 '17 at 6:18
  • @David I'm not able to visit the links that you added in your answer. Can you please share alternate option to understand your answer? – Dhara Bhatti Apr 17 at 12:05
  • @Dhara Bhatti yes, they changed the branch names at some point. I Updated the links to point to the 2.3 develop branch – David Verholen Apr 29 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.