在结帐时添加自定义步骤时激活多个步骤Magento 2

时间:2018-01-25 15:01:33

标签: magento magento2 magento-2.0 magento2.1

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

以下是我试过的代码。

ST /雇员/视图/前端/网络/ JS /视图/ 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();
        }
    });
});

0 个答案:

没有答案