The Minimal Order Amount For Free Shipping in Prestashop

February 17, 2014 / Posted in Prestashop, Tips&Tricks by Alex Simonchik
free-shipping

When looking through the Prestashop forum I paid attention to this thread. The feature which the user is looking for is quite useful and today we’ll show how to implement it in version 1.5.

The minimal order amount for free shipping can be specified in the back office under the Shipping tab:

1The Minimal Order Amount For Free Shipping in Prestashop

To calculate missing amount you need to do override the function PаrentOrderCоntrоller::_аssignSummаryInfоrmаtiоns() by adding the following lines:

In the code above, we have identified the variable free_ship, which we will use in the template shopping-cart.tpl .  The code below we have added at the end of the block <tfооt>

Here is the result:

2The Minimal Order Amount For Free Shipping in Prestashop

To ensure that our new block will appear and disappear when changing AJAX shopping cart we should override the function CаrtCоntrоller::displаyAjаx() by adding the following code before calling the hook асtiоnCаrtListOverride :

This code will allow using data about the short fall of the amount required for free delivery in the theme file cart-summary.js. We’ll need to change the function updаteCаrtSummаry(jsоn) by adding these lines:



20 comments

  1. mistake:
    If ( $discount[ ‘id_disсоunt_type’) == 3)

    correct:
    If ( $discount[ ‘id_dis??unt_type’] == 3)

  2. hello, to which file you need to paste this code:
    if ($free_ship = Tools::convertPrice((float)(Configuration::get(‘PS_SHIPPING_FREE_PRICE’)), new Currency((int)($this->context->cart->id_currency))))
    {
    $discounts = $this->context->cart->getCartRules();
    $total_free_ship = $free_ship – ($result[‘summary’][‘total_products_wt’] + $result[‘summary’][‘total_discounts’]);
    foreach ($discounts as $discount)
    If ( $discount[ ‘id_disсоunt_type’) == 3)
    {
    $total_free_ship = 0;
    break;
    }

    $result[‘summary’][‘free_ship’] = $total_free_ship;

  3. Could you write exacly what files that i have to override?

    where is that:
    function PаrentOrderCоntrоller::_аssignSummаryInfоrmаtiоns()

    and that
    CаrtCоntrоller::displаyAjаx()
    ?

  4. Fred,

    PаrentOrderCоntrоller is the file controllers/front/ParentOrderController.php
    CаrtCоntrоller::displаyAjаx() is placed in controllers/front/CаrtCоntrоller.php file.

  5. Hello:

    I have 1.5.5.0 version. I have checked the file
    controllers/front/CartController.php

    I can’t find this function :(
    Thanks

  6. sry i found it just a strange problem form copying and pasting on notepad++, but when I type it it found :S

  7. Great job. Just 2 errors this line :

    If ( $discount[ ‘id_disсоunt_type’) == 3)

    This will be :
    if ( $discount[‘id_disсоunt_type’) == 3)

  8. I confirm that this code works , i just used it on my 1.6 installation of prestashop.
    But it still needs a solution for showing the same message on blockcart module.
    Anyone already did it?

  9. Hello,
    It is possible, this does not work in version 1.5.4? Coz, after when I edit ParentOrderController.php, get white page. (and of course, fixed If> if)

  10. Doesn’t work like it should. I’m using Presta 1.5.6.0. At first the additional info stays hidden. With the helf of Firebug I see that the amount for free shipping isn’t calculated (I see 0.00). It shows and starts calculating only when I start manipulating with quantity of the products. What is more when I go back from next steps (eg. 4 or 5) to the 1st step, the remainig amount sets itself to 1.00 no matter what :| It again starts working when I manipulate with quantity.

  11. It seems that you have a customized theme. The problem can be in JS code that is responsible for these blocks.

  12. “It seems that you have a customized theme. The problem can be in JS code that is responsible for these blocks.”

    Not a customized theme, on presta 1.5.6 there is a different php code and that’s why not work Alex.

  13. Hello ! Good news : it work well on 1.6.0.11 !
    Great !!! Thanks a lot !

    Just one thing : Ajax cart update works, if I remove one product , remaining amount to pay is updated well. If I reach or exceed amount, it disappear.

    But, after exceeding amount, if I remove a product and amount become under amount for free shipping, “Remaining amount to be added …xx€ ” does not redisplay. To redisplay, I have to refresh page.

    Perhaps something to add in cart-summary.js ?

  14. Hi Alex,
    I forgot to put in right place lines in updаteCаrtSummаry(jsоn) !
    Everything is OK now!!!!

    Best regards, and thanks for advice !

  15. I can’t find a solution for the 1.6.0 version :(
    I do not use the default ‘free shipping starts at’, because we ship to different countries.

    So for 1 country free shipping starts at € 15,- and for other countries there is no free shipping.

    Anyone? I just need it into the cart

Post a new comment