0

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?

method.phtml

 <?php

?>
<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">
                        <span>
                            <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); ?>
                            </label>
                        </span>
                    </div>
                <?php endforeach; ?>
            <?php endforeach; ?>

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

1 Answer 1

0

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.