Jump to content

Add dynamic text field in the AJAX Shopping Cart


Recommended Posts

Hello everyone !

 

On my website (http://lafabrique-e-liza.fr/), I have enabled free shipping fees if the order reaches more than 80€ in the backoffice.

 

I would like to let my customers know that if they order for more than 80€, they'll get free shipping.

 

In order to do so, I edited some files in the blockcart.tpl file, adding the following lines below the "Checkout" button :

{if $total - $shipping_cost < 80}
     <p>
          Livraison gratuite au-delà de 80€.
     </p>
{/if}

Now, I have two issues :

 

1)

 

First of all, with this code, everything runs fine, except that the user has to refresh the page in order to update the "if" condition.

 

For example, if I have ordered for 70€ and add (from the same page) an article, allowing me to reach 80€, the text won't disappear.

The same goes the other way. If there's more than 80€ in my cart, and I delete an item, reaching like 70€, the text won't appear dynamically.

 

I assume this issue is caused by the fact that AJAX doesn't know he has to update the cart block dynamically (at least for this field). Now, how should I do that?

 

2)

 

Secondly, the amount (here 80€) that the user has to reach to get free shipping may be changed in the future.

 

As I do not wish to come back to the code too much after the website is launched, I would like to know how to replace this "80€" with a variable.

I'm assuming it's something like this (but I don't know if the syntax will be read properly, refer to issue 1) :

{if $total - $shipping_cost < $amount_for_free_fees}
     <p>
          Livraison gratuite au-delà de {$amount_for_free_fees}.
     </p>
{/if}

However, I do not know which variable it is that I have to call for, and haven't found any topic about it.

 

 

I've tried some things, but now that I get a basic understanding of how the system works, I can't figure out a way to resolve my issue myself. Any help would definitely be most appreciated. :)

 

Thanks !

Link to comment
Share on other sites

  • 6 months later...

Hi!
Any solution for this?

I want to put "check out" link (button) when the customer put some products in shopping cart (at least one).

This code makes the job but customer need to refresh page to view "check out" link (button)

{if $cart_qties > 0}    
        <a href="{$link->getPageLink("$order_process", true)|escape:'html'}" title="{l s='Check out'}" rel="nofollow"><span></span>{l s='Check out' }</a>
{/if}

Any hint for that trick?

 

 

EDIT
I found solution for this :)
Without {if $cart_qties > 0} 
 

<span class="ajax_cart_product_txt{if $cart_qties == 0} hidden{/if}">
            <a href="{$link->getPageLink("$order_process", true)|escape:'html'}" title="{l s='Check out' mod='blockcart'}" rel="nofollow">{l s='Check out' mod='blockcart'}</a>
</span>

This class makes the job

class="ajax_cart_product_txt{if $cart_qties == 0} hidden{/if}

 

So You need to make something like this

<span class="ajax_cart_product_txt{if $total - $shipping_cost < 80} hidden{/if}">
Livraison gratuite au-delà de 80€.
</span>

Try it :)
 

Edited by kisweb (see edit history)
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...