2

I have table rates shipping enabled. Any order over £100 has free shipping.

However, if a discount code is applied that takes it under £100, shipping should be charged. In Magento 2 this is not currently the case, it chooses shipping options based on the total prior to the discount being applied.

Can anyone suggest an update so shipping is calculated on the final value of the order (i.e. after discount codes are applied).

1
  • have you managed to solve the issue using table rates? Commented Nov 29, 2019 at 11:31

1 Answer 1

2

There are several ways to provide Free Shipping. In your case you are doing it through the Table Rates but if you want to get the correct result I would recommend to use a Cart Price Rule to provide free shipping.

More information how you can configure a Cart Price Rule see https://docs.magento.com/m2/ce/user_guide/marketing/price-rules-cart.html

Free Shipping

Determines if free shipping is included in the promotion, and if so, for which items. Options:

No

Free shipping is not available when a coupon that is based on the rule is used.

For matching items only

Free shipping is available only for specific items in the cart that match the rule.

For shipment with matching items

Free shipping is available for the entire cart when a coupon that is based on the rule is used.

But if you really want to do it through a cod changes then take a look around line 101 and 12 in file:

vendor/magento/module-offline-shipping/Model/Carrier/Tablerate.php

Here you can change the getPackageValue to getPackageValueWithDiscount.

4
  • Thanks Mr Lewis, but we have shipping available across different countries, and different prices for various post codes - so this may not work for us. The calculation seems to be done on an items price prior to any discount being applied... and I wonder if I can edit a file/create a module to calculate based on final price (after code). Commented Dec 3, 2018 at 15:23
  • @YorkieMagento see my updated answer for more information
    – Mr. Lewis
    Commented Dec 3, 2018 at 16:07
  • Thanks @Mr. Lewis, the second option is what I need. Can I edit this and save within my own template file/module?... any idea how I'd go about that. I no it's not good practice to override Mage core files. Commented Dec 31, 2018 at 10:58
  • Is this proper solution to change 'getPackageValue'? Commented Oct 2, 2019 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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