0

Magento 2.2.6 When we do order offline,Payment validation not working.

I tried

<?php if ($block->hasMethods()) : ?>
    <div id="order-billing_method_form">
        <dl class="admin__payment-methods">
            <?php
                $_methods = $block->getMethods();
                $_methodsCount = count($_methods);
                $_counter = 0;
                $currentSelectedMethod = $block->getSelectedMethodCode();
            ?>
            <?php foreach ($_methods as $_method) :
                $_code = $_method->getCode();
                $_counter++;
            ?>
                <dt class="admin__field-option">
                    <?php if ($_methodsCount > 1) : ?>
                        <input id="p_method_<?= $block->escapeHtml($_code); ?>"
                               value="<?= $block->escapeHtml($_code); ?>"
                               type="radio" name="payment[method]"
                               title="<?= $block->escapeHtml($_method->getTitle()); ?>"
                               onclick="payment.switchMethod('<?= $block->escapeHtml($_code); ?>')"
                            <?php if ($block->getSelectedMethodCode() == $_code) : ?>
                                checked="checked"
                            <?php endif; ?>

                               class="admin__control-radio"
                                **[![enter image description here][1]][1]**data-validate="{'validate-one-required-by-name':true}"/>****
                    <?php else : ?>
                        <span class="no-display">
                            <input id="p_method_<?= $block->escapeHtml($_code); ?>"
                                   value="<?= $block->escapeHtml($_code); ?>"
                                   type="radio"
                                   name="payment[method]" class="admin__control-radio"
                                   checked="checked"/>
                        </span>
                    <?php endif; ?>

                    <label class="admin__field-label" for="p_method_<?= $block->escapeHtml($_code); ?>">
                        <?= $block->escapeHtml($_method->getTitle()) ?>
                    </label>
                </dt>
                <dd class="admin__payment-method-wrapper">
                    <?= /* @noEscape */ $block->getChildHtml('payment.method.' . $_code) ?>
                </dd>
            <?php endforeach; ?>
        </dl>
    </div>
    <script>
        require([
            'mage/apply/main',
            'Magento_Sales/order/create/form'
        ], function(mage) {
            mage.apply();
        <?php if ($_methodsCount != 1) : ?>
            order.setPaymentMethod('<?= $block->escapeHtml($currentSelectedMethod); ?>');
        <?php else : ?>
            payment.switchMethod('<?= $block->escapeHtml($currentSelectedMethod); ?>');
        <?php endif; ?>
        });
    </script>
<?php else : ?>
    <div class="admin__message-empty"><?= $block->escapeHtml(__('No Payment Methods')); ?></div>
<?php endif; ?>

I used data-validate="{'validate-one-required-by-name':true}"

But its not working in 2.2.6 , its working fine in 2.3.1.

Note- This issue is only coming with "Virtual Product".

Admin Order Create

please help

Your Answer

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

Browse other questions tagged or ask your own question.