Jump to content
  • 0
antonio.soleres

Remaining amount to be added to your cart in order to obtain free shipping

Question

In Prestashop 1.5.2, is there any way that in the shopping cart appears the following information: “Remaining amount to be added to your cart in order to obtain free shipping”, as appeared in version 1.4.8.2?

Thanks.

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Thanks for your answer.

So There is 2way.

  1. Find a module which offer this function
  2. Developa module which offer this function

But I'm surprise a so useful function, disapear ?!

Share this post


Link to post
Share on other sites
  • 0

Thanks Alex but i don't find where to put the code i don't see the function :( ps 1.5.5.0


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



 




1

2

3

4

5

6

7

8

9

10

11

12

13

14





...

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 - ($summary['total_products_wt'] + $summary['total_discounts']);

    foreach ($discounts as $discount)

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

        {

            $total_free_ship = 0;

            break;

        }

   $summary['free_ship'] = $total_free_ship;

}

...





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



 




1

2

3

4

5

6





...

<tr class="remaining_cart_free_shipping" {if $free_ship <= 0 || $isVirtualCart} style="display: none;" {/if}>

    <td colspan="6" style="white-space: normal;">{l s='Remaining amount to be added to your cart in order to obtain free shipping:'}</td>

    <td id="free_shipping" class="price">{displayPrice price=$free_ship}</td>

</tr>

...





Here is the result:


 


21.png


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 :



 




1

2

3

4

5

6

7

8

9

10

11

12

13

14

15






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;

}

...





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:



 




1

2

3

4

5





if (json.free_ship >= 0) {

    $(".remaining_cart_free_shipping").show();

} else {

    $(".remaining_cart_free_shipping").hide();

}





Thanks for your help


Share this post


Link to post
Share on other sites

×