I have added a js in Magestore/OneStepCheckout/view/frontend/web/js/ customtemplate.js

define(
    [
        'ko',
        'uiComponent'
    ],
    function (ko, Component) {
        "use strict";

        return Component.extend({
            alert('load custom template');
            defaults: {
                template: 'Magestore_OneStepCheckout/customtemplate'
            },
            isChosed: function() {
             if ($('#education').is(":checked"))
                {
                 alert('education');
                }
            if ($('#health').is(":checked"))
                {
                 alert('health');
                }
            if ($('#environment').is(":checked"))
                {
                 alert('environment');
                }
            }
        });
    }
);

Magestore/OneStepCheckout/view/frontend/web/template/customtemplate.html

<table class="data-table">
                                            <tr class="first odd">
                                            <th class="a-left" rowspan="1" style="width:65%">
                                            <input type="checkbox" name="education" data-bind="checked: isChosed, attr: {id: 'education'}" />
                                            <span data-bind="i18n: 'Chose Education'"></span>
                                            </th>
                                            </tr>
                                            <tr>
                                            <th class="a-left" rowspan="1" style="width:65%">
                                            <input type="checkbox" name="health" data-bind="checked: isChosed, attr: {id: 'health'}" />
                                            <span data-bind="i18n: 'Chose Health'"></span>
                                            </th>
                                        </tr>
                                            <tr>
                                            <th class="a-left" rowspan="1" style="width:65%">
                                            <input type="checkbox" name="environment" data-bind="checked: isChosed, attr: {id: 'environment'}"/>
                                            <span data-bind="i18n: 'Chose Environment'"></span>
                                            </th>
                                        </tr>
                                        </table>

add js and template in Magestore/OneStepCheckout/view/frontend/layout/onestepcheckout_layout.xml

<item name="custom-template" xsi:type="array">
                                                    <item name="provider" xsi:type="string">checkoutProvider</item>
                                                    <item name="component" xsi:type="string">Magestore_OneStepCheckout/js/view/customtemplate</item>
                                                    <item name="template" xsi:type="string">Magestore_OneStepCheckout/customtemplate</item>
                                                    <item name="displayArea" xsi:type="string">shipping-method</item>
                                                    <item name="children" xsi:type="array">
                                                    </item>
                                                </item>

i am getting error in console Failed to load the "Magestore_OneStepCheckout/js/view/customtemplate" component.

有帮助吗?

解决方案

Change

<item name="component" xsi:type="string">Magestore_OneStepCheckout/js/view/customtemplate</item>

To

<item name="component" xsi:type="string">Magestore_OneStepCheckout/js/customtemplate</item>
许可以下: CC-BY-SA归因
scroll top