0

我在结帐时添加了一个自定义步骤,因为下一步也会与自定义步骤一起激活。由于我的报价是虚拟的,因此运输步骤是隐藏的,只有自定义步骤和付款步骤会一起显示。

以下是我尝试过的代码。

ST/Employees/view/frontend/web/js/view/login.js

define(
[
    'ko',
    'uiComponent',
    'underscore',
    'Magento_Checkout/js/model/step-navigator'
],
function (
    ko,
    Component,
    _,
    stepNavigator
) {
    'use strict';
    /**
    *
    * mystep - is the name of the component's .html template,
    * <Vendor>_<Module>  - is the name of the your module directory.
    *
    */
    return Component.extend({
        defaults: {
            template: 'ST_Employees/login'
        },

        //add here your logic to display step,
        isVisible: ko.observable(true),

        /**
        *
        * @returns {*}
        */
        initialize: function () {
            this._super();
            // register your step
            stepNavigator.registerStep(
                //step code will be used as step content id in the component template
                'login',
                //step alias
                null,
                //step title value
                'Collection Point',
                //observable property with logic when display step or hide step
                this.isVisible,

                _.bind(this.navigate, this),

                /**
                * sort order value
                * 'sort order value' < 10: step displays before shipping step;
                * 10 < 'sort order value' < 20 : step displays between shipping and payment step
                * 'sort order value' > 20 : step displays after payment step
                */
                0
            );

            return this;
        },

        /**
        * The navigate() method is responsible for navigation between checkout step
        * during checkout. You can add custom logic, for example some conditions
        * for switching to your custom step
        */
        navigate: function () {
            self.visible(false);
        },

        /**
        * @returns void
        */
        navigateToNextStep: function () {
            stepNavigator.next();
        }
    });
});
4

0 回答 0