Question

enter image description here

How to precheck I already agree term and conditions checkbox on checkout page? I want to precheck i already agree Term and conditions on checkpage in magento.

Was it helpful?

Solution

You can override that checkout-agreements.html file in your theme :

app/design/frontend/VendorName/ThemeName/Magento_CheckoutAgreements/web/template/checkout/checkout-agreements.html

You just need to add 'checked': 'checked' attribute in checkbox field. So, just copy below code and paste in your file.

<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<div data-role="checkout-agreements">
    <div class="checkout-agreements" data-bind="visible: isVisible">
        <!-- ko foreach: agreements -->
            <!-- ko if: ($parent.isAgreementRequired($data)) -->
            <div class="checkout-agreement required">
                <input type="checkbox" class="required-entry"
                       data-bind="attr: {
                                    'id': $parent.getCheckboxId($parentContext, agreementId),
                                    'name': 'agreement[' + agreementId + ']',
                                    'value': agreementId,
                                    'checked': 'checked',
                                    }"/>
                <label data-bind="attr: {'for': $parent.getCheckboxId($parentContext, agreementId)}">
                    <button type="button"
                            class="action action-show"
                            data-bind="click: function(data, event) { return $parent.showContent(data, event) }"
                            >
                        <span data-bind="html: checkboxText"></span>
                    </button>
                </label>
            </div>
            <!-- /ko -->
            <!-- ko ifnot: ($parent.isAgreementRequired($data)) -->
            <div class="checkout-agreement">
                <button type="button" class="action action-show"
                        data-bind="click: function(data, event) { return $parent.showContent(data, event) }">
                    <span data-bind="html: checkboxText"></span>
                </button>
            </div>
            <!-- /ko -->
        <!-- /ko -->
        <div id="checkout-agreements-modal" data-bind="afterRender: initModal" style="display: none">
            <div class="checkout-agreements-item-content" data-bind="html: modalContent"></div>
        </div>
    </div>
</div>

Now, clean cache and check your output. Cheers :)

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top