Jira Code: TC – 111
If we need to remove a shipping method from a SCA website using code we can do it in code. In order to do these, we need to customizeOrderWizard.Module.Shipmethod.js. In the getContext method, reject the shipping method by specifying it’s name
EditOrderWizard.Module.Shipmethod.js file
, getContext: function getContext ()
{
var self = this
, show_enter_shipping_address_first = !this.model.get('isEstimating') && !this.profileModel.get('addresses').get(this.model.get('shipaddress'))
, shipping_methods = this.model.get('shipmethods').map(function (shipmethod)
{
return {
name: shipmethod.get('name')
, rate_formatted: shipmethod.get('rate_formatted')
, internalid: shipmethod.get('internalid')
, isActive: shipmethod.get('internalid') === self.model.get('shipmethod')
};
});
var sorted_shipping_methods = shipping_methods .sort(function(a,b) {
var firstValue = a.name.length;
var secValue = b.name.length;
return (firstValue > secValue) ? 1 : ((secValue > firstValue) ? -1 : 0);
}
);
var taipan_Shipping_methods = _.reject(sorted_shipping_methods, function(
method
) {
return method.name == "FREE SHIPPING (excludes Wire, Electrode, Cable)";
});
//@class OrderWizard.Module.Shipmethod.Context
return {
//@property {LiveOrder.Model} model
model: this.model
//@property {Boolean} showEnterShippingAddressFirst
, showEnterShippingAddressFirst: show_enter_shipping_address_first
//@property {Boolean} showLoadingMethods
, showLoadingMethods: this.reloadingMethods
//@property {Boolean} hasShippingMethods
, hasShippingMethods: !!shipping_methods.length
//@property {Boolean} display select instead of radio buttons
, showSelectForShippingMethod: shipping_methods.length > 5
//@property {Array} shippingMethods
, shippingMethods: taipan_Shipping_methods
//@property {Boolean} showTitle
, showTitle: !this.options.hide_title
//@property {Straing} title
, title: this.options.title || _('Delivery Method').translate()
};