Prevent Free Shipping When a Handling Fee is Applied

  • We need to add the following code :
  • try {
  •                 _.extend(OrderWizardModuleShipmethod.prototype, {
  •                     getContext: _.wrap(OrderWizardModuleShipmethod.prototype.getContext, function (fn) {
  •                         const context = fn.apply(this, _.toArray(arguments).slice(1));
  •                         const handlingCost = this.model.get('summary').handlingcost;
  •                         console.log('handlingCost', handlingCost);
  •  
  •                         if (context.shippingMethods && context.shippingMethods.length) {
  •                             context.shippingMethods.forEach(method => {
  •                                 // Find the corresponding model to get the raw rate value
  •                                 const matchingModel = this.model.get('shipmethods').findWhere({ internalid: method.internalid });
  •                                 if (matchingModel) {
  •                                     const rate = matchingModel.get('rate');
  •                                     method.hideDueToHandling = rate === 0 && handlingCost > 0;
  •                                 } else {
  •                                     method.hideDueToHandling = true;//false;
  •                                 }
  •                             });
  •                         }
  •  
  •                         return context;
  •                     })
  •                 });
  •             }
  •             catch (e) {
  •                 console.log('Error extending OrderWizardModuleShipmethod', e);
  •             }

Also, we need to add a context variable in the corresponding template.

Leave a comment

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