Prestashop 1.7.4.2 - free shipping based on final total price

1.2k Views Asked by At

I need shipping calculation after discount applied

Ex.
Total cart : 65$
Free shipping start : 65$
Discount : 5%

After discount it become under 65$ and still get free shipping I need it to calculate discount before shipping

2

There are 2 best solutions below

1
Tidiane AW On BEST ANSWER

First set your ranges by carrier (0-65: X EUR, above 65: 0 EUR)

Do an override of the class Cart.php

Rewrite function getPackageShippingCost

After line

// Order total in default currency without fees
$order_total = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);

Add this

//Recalcul total pour panier et livraison gratuite 
$listeDiscounts = $this->getCartRules();        
$total_discounts = 0;
if (is_array($listeDiscounts)) {
    if (isset($listeDiscounts[0]['value_real']))
        $total_discounts = $listeDiscounts[0]['value_real'];            
}
$price_to_apply_shipment = floatval($order_total) - floatval($total_discounts);

Replace

//$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int)$id_zone, (int)$this->id_currency);
by                    
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $price_to_apply_shipment, (int)$id_zone, (int)$this->id_currency);

And

//$shipping_cost += $carrier->getDeliveryPriceByPrice($the_total_price, $id_zone, (int)$this->id_currency);
By 
$shipping_cost += $carrier->getDeliveryPriceByPrice($price_to_apply_shipment, $id_zone, (int)$this->id_currency);

Clear the cache and run

0
Uladzimir On

The bottom two changes can be replaced by:

 $total_package_without_shipping_tax_inc 
    = $order_total 
    = $orderTotalwithDiscounts 
    = $price_to_apply_shipment;

These variables are only used in these two places along the way