0

I want to hide this new address button based on customer group. I want to use conditions for hiding that button. If anyone knows please let me know.

magento

Check still loading

Check this still loadind and console.

0

Try the following way:

app/code/SR/MagentoCommunity/view/frontend/requirejs-config.js

var config = {
    config: {
        mixins: {
            'Magento_Checkout/js/view/shipping': {
                'SR_MagentoCommunity/js/mixin/shipping-mixin': true
            }
        }
    }
};

app/code/SR/MagentoCommunity/view/frontend/web/js/mixin/shipping-mixin.js

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

        return function (target) {
            return target.extend({
                /**
                 * @inheritDoc
                 */
                initialize: function () {
                    this._super();
                    var self = this;
                    var quoteData = window.checkoutConfig.quoteData;
                    var customerGroupId = parseInt(quoteData.customer_group_id);
                    if (!this.isFormInline) {
                        _.each([3,4], function (value) {
                            if (value == customerGroupId) {
                                self.isNewAddressAdded(true);
                            }
                        } );
                    }
                    return this;
                }
            });
        }
    }
);
| improve this answer | |
  • Brother @sohel I want to show this button for two customer groups so what would be the code ? – Yousaf Apr 23 at 14:21
  • My checkout page is loading stll and not working properly. can you update ? – Yousaf Apr 23 at 14:56
  • You modify this logic: if (!this.isFormInline && (customerGroupId != 4)) { – Sohel Rana Apr 23 at 15:10
  • Remove static content, build static content – Sohel Rana Apr 23 at 15:11
  • I removed static content but checkout is still loading. Is this code working for you ? – Yousaf Apr 23 at 15:14

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.