Jump to content

How to exclude gifts prices from total shipping


lkanada

Recommended Posts

Hello,

I have a problem with my prestashop (1.5).

 

I have configured FREE SHIPPING for orders >= 60€

 

The problem is when new gifts are added: I want not to consider this prices to calcuate the total shipping.

 

For exemple, if I have a total amount of 59€ in products and a gift of 1€, the system consider FREE SHIPMENT because adds the 1€ of the gift.

 

The customer is only shopping 59€ and the system considers 60€.

 

Is thery any hack to solve this problem?

 

Thank you ;)

Link to comment
Share on other sites

  • 8 months later...
  • 1 year later...

Good afternoon,

 

Better late then never I guess...  :)

 

I actually found a pretty easy fix for this in Presta 1.6, I'm sorry if it doesn't work in other versions.

Also pay attention that you have to change a core class in PrestaShop.

 

It concerns the function "getPackageShippingCost()" in the Cart class (classes/Cart.php);

There I've changed:

$order_total = $this->getOrderTotal(false, Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING, $product_list);

Into:

//get cart rules for discount amount, so the gift product doesn't get included in the shipping cost
$cart_rules = $this->getCartRules();
$total_free_gifts = 0;

foreach($cart_rules as $cart_rule){
if($cart_rule['gift_product'] != ""){
$value = $cart_rule['value_tax_exc'];
$total_free_gifts += $value;
}
}

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

//exclude free gifts from order total
$order_total = $order_total - $total_free_gifts;

Hope this helps anyone.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...