Jump to content

Do not include shipping cost for Free Shipping.


mytheory.
 Share

Recommended Posts

Hello,

I recently noticed that the shipping cost is included in the total amount towards the free shipping threshold.

So for example, lets assume the free shipping threshold amount is set at $50 in the BO and the shipping cost is $10. The customer buys/adds a product costing $45. In the right scenario, the customer should not be eligible for free shipping. However, PS currently adds the shipping cost to the total amount and then determines whether it qualifies for free shipping. So in this situation, PS returns a total of $55 (product cost + shipping cost) and gives the customer free shipping.

If the product cost 49.99 it wouldn't be a big deal, but with this setup the customer technically only needs to buy $40 worth of products and not $50 to receive free shipping. And it would be odd to increase the free shipping threshold to $60 just to compensate.

Is there anyway to setup PS to use the total amount of the products (not including shipping cost) as the basis for determining free shipping? So if the total amount before shipping is above $50 then the customer qualifies for free shipping... and if not then shipping cost is still added.

Hope this makes sense.

Thanks!

Share this post


Link to post
Share on other sites

It is the following code on lines 832-834 of classes/Cart.php (in PrestaShop v1.3.1) that handles the free shipping:

$orderTotalwithDiscounts = $this->getOrderTotal(true, 4);
if ($orderTotalwithDiscounts >= floatval($free_fees_price) AND floatval($free_fees_price) > 0)
   return $shipping_cost;



Here's the code sheet for the getOrderTotal function:

type = 1: only products
type = 2: only discounts
type = 3: both
type = 4: both but without shipping
type = 5: only shipping
type = 6: only wrapping
type = 7: only products without shipping



Since the parameter 4 is being used, it seems it is already subtracting the discounts and shipping from the total before comparing it to the "Free shipping at" value. I'm not sure why it isn't working for you. I suppose you can try different parameter codes to see whether you get the desired result.

Share this post


Link to post
Share on other sites

As always thanks rocky!

I am using PS version 1.2.5... was this something that was fixed in 1.3.1 or did this part of the code remain unchanged between the two versions?

I don't have access to my server at the moment so I can check the code, but as soon as I can (hopefully sometime this weekend) I will double check it and report back.

thanks again rocky!

Share this post


Link to post
Share on other sites

Yep, it looks like it was something that was fixed in PrestaShop v1.3. I just checked and this is the code in PrestaShop v1.2.5:

// Free fees
if (isset($configuration['PS_SHIPPING_FREE_PRICE']) AND $orderTotal >= floatval($configuration['PS_SHIPPING_FREE_PRICE']) AND floatval($configuration['PS_SHIPPING_FREE_PRICE']) > 0)
   return $shipping_cost;
if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) AND $this->getTotalWeight() >= floatval($configuration['PS_SHIPPING_FREE_WEIGHT']) AND floatval($configuration['PS_SHIPPING_FREE_WEIGHT']) > 0)
   return $shipping_cost;



and this is the code in PrestaShop v1.3.1:

// Free fees
$free_fees_price = 0;
if (isset($configuration['PS_SHIPPING_FREE_PRICE']))
   $free_fees_price = Tools::convertPrice(floatval($configuration['PS_SHIPPING_FREE_PRICE']), new Currency(intval($this->id_currency)));
$orderTotalwithDiscounts = $this->getOrderTotal(true, 4);
if ($orderTotalwithDiscounts >= floatval($free_fees_price) AND floatval($free_fees_price) > 0)
   return $shipping_cost;
if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) AND $this->getTotalWeight() >= floatval($configuration['PS_SHIPPING_FREE_WEIGHT']) AND floatval($configuration['PS_SHIPPING_FREE_WEIGHT']) > 0)
   return $shipping_cost;

Share this post


Link to post
Share on other sites

I think it would be better for you to copy the entire getOrderShippingCost function from v1.3.1 rather than just part of it. I'm not sure whether it will cause any problems though. You really should upgrade your entire installation to PrestaShop v1.3.1.

Share this post


Link to post
Share on other sites

  • 4 weeks later...

Hello Rocky,

Was looking at the code and it seems like you are right about v1.3 fixing discounts issue, but one thing that it does include is the taxes. Taxes shouldn't count toward the free shipping. I tried changing the
$orderTotalwithDiscounts = $this->getOrderTotal(true, 4)

to

$orderTotalwithDiscounts = $this->getOrderTotal(true, 1)

which is the product total, but I am getting a "can't process this directive" when I do this. Any ideas?

Thanks

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More