I'm trying to get the customer to choose the shipping because many people just continue without checking the shipping method. We need it to not already be checked and be required. What do I need to change on this file?



<div id="xxx-checkout_shipping_method">
    <div class="shipping-method-holder" >

        <?php if ($groups = $block->getShippingRateGroups()): ?>
            <?php $currentRate = $block->getCurrentShippingRate(); ?>
            <?php foreach ($groups as $code => $rates): ?>
                <?php if (0): ?><strong><?php echo $block->escapeHtml($block->getCarrierName($code)) ?></strong><?php endif; ?>
                <?php foreach ($rates as $rate):
                    $value = $block->escapeHtml($block->renderShippingRateValue($rate));
                    $checked = $currentRate === $rate->getCode() ? 'checked' : '';
                    <div class="xxx-checkout-radio-row">
                            <input type="radio"
                                   name="shipping_method" <?php echo $checked; ?> value="<?php echo $value; ?>"
                                   id="<?php echo $value; ?>">
                            <label for="<?php echo $value; ?>">
                                <?php /* @noEscape */
                                echo $block->renderShippingRateOption($rate); ?>
                <?php endforeach; ?>
            <?php endforeach; ?>

        <?php else: ?>
                    <?php echo $block->escapeHtml(__('Sorry, no quotes are available for this order right now.')); ?>
        <?php endif; ?>

1 Answer 1


Since this seems in the normal PHTML, instead of Knockout.

So, In this, if you are posting the form-data directly then just add one JS validation and, do the validation in the JS that if value exists for the shipping method then only post the data.

Take the reference of this solution https://magento.stackexchange.com/a/272379/71417

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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