0

I know that there is basic functionality, but it does not suit me.

How to display my template under the form with the link to the privacy-policy page?

Or tell me how to do it right. I need a checkbox under the form that asks to confirm that the privacy policy has been read.

I create a js file: app/design/frontend/Vendor/theme/Magento_Checkout/web/js/checkout-privacy.js

define(
    ['ko', 'uiComponent'],
    function (ko, Component) {
        "use strict";
        return Component.extend({
            defaults: {
                template: 'Magento_Checkout/checkout-privacy/checkout-privacy'
            }
        });
    }
);

and file: app/design/frontend/Vendor/theme/Magento_Checkout/web/template/checkout-privacy/checkout-privacy.html

<form id="checkbox-policy-form" data-mage-init='{"validation":{}}'>
    <input type="checkbox" class="checkbox-policy input required-entry" data-validate="{ required: true, 'validate-one-required-by-name': true, attr: { id: 'checkbox-policy' }}">
    <label class="label" data-bind="attr: {for: 'checkbox-policy'}">
        <span data-bind="i18n: 'I agree to the'"></span>
        <a href="checkbox-policy" data-bind="i18n: 'Terms and Conditions'"></a>
    </label>
</form>

<script type="text/x-magento-init">
    {
        "#checkbox-policy-form": {
            "validation": {}
        }
    }
</script>

on payment step

4
  • Terms and Conditions you are enable in admin panel ??? Commented Jun 8, 2020 at 18:23
  • @MohitPatel This functionality does not suit me, it calls popup with text, but I need something without a mandatory checkbox in which part of the text is a link to the "privacy-policy" page. Like - <span data-bind="i18n: 'I agree to the'"></span><a href="checkbox-policy" data-bind="i18n: 'Terms and Conditions'"></a> Commented Jun 8, 2020 at 18:26
  • check this link --- meetanshi.com/blog/add-magento-2-terms-and-conditions-checkbox Commented Jun 8, 2020 at 18:27
  • @MohitPatel I don't need popup, this method is not for me, I know how to turn it on but it doesn’t suit me Commented Jun 8, 2020 at 18:32

1 Answer 1

0

check ur layout

use this one as an example

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="checkout.root">
        <arguments>
            <argument name="jsLayout" xsi:type="array">
                <item name="components" xsi:type="array">
                    <item name="checkout" xsi:type="array">
                        <item name="children" xsi:type="array">
                            <item name="steps" xsi:type="array">
                                <item name="children" xsi:type="array">
                                    <item name="billing-step" xsi:type="array">
                                        <item name="children" xsi:type="array">
                                            <item name="payment" xsi:type="array">
                                                <item name="children" xsi:type="array">
                                                    <item name="beforeMethods" xsi:type="array">
                                                        <item name="children" xsi:type="array">
                                                            <item name="privacy-policy" xsi:type="array">
                                                                <item name="component" xsi:type="string">Magento_Checkout/js/checkout-privacy</item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>
</body>

1
  • Thank you, but how to do this as part of the form and check when submit? At the moment, the component displays under payment methods Commented Jun 8, 2020 at 19:07

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.