Calculate Shipping Charge After Discount Applied in Magento 2

discountmagento2shipping-methodssubtotaltax

I need to calculate shipping charge after discount is applied on cart subtotal

for example
cart subtotal: $170.00
Discount: -$15.00
Shipping: $17.00

Here i want it to calculate shipping charges after discount is added to cart subtotal,

for example
cart subtotal: $170.00
    Discount: -$15.00
    Shipping: $15.50

because it should first remove $15 from $170 and then it should calculate shipping charges from the remaining one.

Can you anyone please tell me the way to do this or any workaround for it

thanks in advance

Best Answer

I have added this in my custom shipping method, and it works for me. This should be added on your collectrates function inside your module.

$s_price = $request->getPackageValueWithDiscount();
$request->setPackageValue($s_price);
Related Topic