Restrict the country in shipping and billing address of a customer in the website based on the customer subsidiary

Requirement is to restrict the country in shipping and billing address of a customer in the website based on the customer subsidiary in myaccount and checkout pages.  

For that we need to extend the’ Global.Views.Countries.Dropdown.View’ and adding the code below

_.extend(GlobalViewsCountriesDropdownView.prototype, {
getContext: _.wrap(GlobalViewsCountriesDropdownView.prototype.getContext, function (fn) {
var context = fn.apply(this, _.toArray(arguments).slice(1));
var profile = ProfileModel.getInstance();
try {
if (profile.get('isLoggedIn') === 'T') {
var subsidiary = profile.get('subsidiary')
if (subsidiary === '4') {
   var countrys = context.countries;
    var line = []										   line.push(_.findWhere(countrys, { code: 'NZ' }));										  context.countries = line
   }
if (subsidiary === '7') {
	var countrys = context.countries;
	var line = []									line.push(_.findWhere(countrys, { code: 'US' }));										context.countries = line
	}
if (subsidiary === '1') {
	var countrys = context.countries;
	var line = []										line.push(_.findWhere(countrys, { code: 'AU' }));										context.countries = line
		}
	}
}
	catch (e) {
		console.log("error in catch JJ", e)
		}

	return context
})
});

Leave a comment

Your email address will not be published. Required fields are marked *