1

I'am adding a new validation rule.

The result should depend on storeview code.

How can I get the storeId in the following javascript code?

validator-mixin.js

define([
    'jquery'
], function ($) {
    'use strict';

    return function (validator) {

        validator.addRule(
            'validate-myrule',
            function (value, params) {

                //my rule logic which needs to know storeId

            },
            $.mage.__("rule error message")
        );

        return validator;
    };
});
1

You can use the window.checkout to get the websiteId enter image description here

  • the websiteId is not storeviewId. Thanks anyway! – hippoglollum Aug 29 '18 at 7:38
  • It looks like window.checkout.storeId is now available. – strangerpixel Apr 8 at 15:46
1

You can use website id in js for conditions

var websiteId = window.checkout.websiteId;
  • the websiteId is not storeviewId. Thanks anyway! – hippoglollum Aug 29 '18 at 7:38
0

Try this, This works on the checkout page.

window.checkoutConfig.storeCode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.