Jump to content

[free tutorial] "product added to cart" notification bar


Recommended Posts

If I have a 3 item in stock for a product and customer place a order for 5 then prestashop pop up message “not enough products in stock” at the same time confirmation bar appear with message product added to cart.  But in fact product is not added because there are not enough in stock.  I found a post on prestshop which say to add   
if (!jsonData.hasError) 

{

$('#addtocartpopup').fadeIn(500).delay(2000).fadeOut(500);

}

 

I would like to know what should I add to this code and where it should be placed in javascript to stop confirmation bar coming up if enough product is not in stock.

 

Post where I found the code:- http://www.prestasho...d-to-cart-text/

 

Once again thanks the for tutorial

Edited by Zen_j1 (see edit history)

Share this post


Link to post
Share on other sites
If I have a 3 item in stock for a product and customer place a order for 5 then prestashop pop up message “not enough products in stock” at the same time confirmation bar appear with message product added to cart.  But in fact product is not added because there are not enough in stock.  I found a post on prestshop which say to add   
if (!jsonData.hasError) 

{

$('#addtocartpopup').fadeIn(500).delay(2000).fadeOut(500);

}

 

I would like to know what should I add to this code and where it should be placed in javascript to stop confirmation bar coming up if enough product is not in stock.

 

Post where I found the code:- http://www.prestasho...d-to-cart-text/

 

Once again thanks the for tutorial

 

Solution:-

 

 

if(!jsonData.errors)

                    {

                    $("body").append("<div class='addtocartconfirmation'><span>"+addtocartconfirmation+"</span></div>"); $(".addtocartconfirmation").fadeOut(8000);

                    }

  • Like 1

Share this post


Link to post
Share on other sites
  • 5 months later...
  • 3 weeks later...
  • 1 month later...

Quick info for doing this in 1.6

 

Steps from original tutorial:

1. Instead of header.tpl, open global.tpl and add

{addJsDefL name=addtocartconfirmation}{l s='Product successfully added to cart'}{/addJsDefL}

just before the {/strip} on the last line.

2. The same, but the line is near 318 instead of 208,

3. No change..

 

4. Translation - Select Front-Office translations and your theme, search for global. There your text should be seen, below Close, Next, Previous translations

 

5. Optional - Disable the default enormus popup

search for

updateLayer : function(product){

around line 716.

comment everything inside the { } (Line 717 to 731)

Edited by PhpMadman (see edit history)
  • Like 3

Share this post


Link to post
Share on other sites

Thanks a TON Php Madman :)

 

 

This worked perfectly ....

 

Also, i was trying to add   

 

{addJsDefL name=addtocartconfirmation}{l s='Successfully added'}{$product_name}{l s='to cart'}{/addJsDefL}

 

but i am not able to call the product name here.. am i doing something wrong ?? appreciate your help

Share this post


Link to post
Share on other sites

To assign product name, you have to add it to every tpl file that has a add_to_cart button.

{addJsDef product_name=$product->name} // Can be $product.name or $product['name'] depending on file
{addJsDefL name=addtocart_succses}{l s='Successfully added '}{/addJsDefL} // Notice the space at end
{addJsDefL name=addtocart_tocart}{l s=' to cart'}{/addJsDefL} // space at start

and in the js file instead of +addtocartconfirmation+ it would be this +addtocart_succses+product_name+addtocart_tocart

 

Untested, but something like that is requierd

  • Like 1

Share this post


Link to post
Share on other sites

Thanks again,.. You Rock PhpMadman :)

 

I did change all tpl files where i could get add_to_cart, notification is perfectly working when i access it from Quick View or individual Product Page.

 

But i am getting NULL if i do it from category list or homepage :(

 

i am not able to find any other tpl where add_to_cart is available. If you could let me know if i am missing something, it will be really helpful

Share this post


Link to post
Share on other sites
  • 2 weeks later...
  • 10 months later...

Thank you for this tuto ! 

 

Just a question, I try to add a link "view your shopping bag" below the button "add to bag". 

I have code : 

 

> Ajax-cart.js : $(".box-cart-bottom").append("<div class='checkout_txt'><span>"+checkout_txt+"</span></div>");

 

> Global.tpl : {addJsDefL name=checkout_txt}{l s='View your shopping bag'}{/addJsDefL}

 

My problem, every time I click on add to bag button, a link "View your shopping bag" appear. 

So if I click 5 times, 5 link appear…  :unsure:

 

How can I do please ?

 

Julien

Edited by julesfromparis (see edit history)

Share this post


Link to post
Share on other sites

There is a "solution" using the product.tpl file but the problem is that the link "View your shopping bag" is displayed on all product pages whenever there is a product in the bag… 

{if $cart_qties > 0}
  <a href="{$link->getPageLink($order_process, true)}" class="checkout-button">Checkout</a>
{/if}

Share this post


Link to post
Share on other sites

Thank you for this tuto ! 

 

Just a question, I try to add a link "view your shopping bag" below the button "add to bag". 

I have code : 

 

> Ajax-cart.js : $(".box-cart-bottom").append("<div class='checkout_txt'><span>"+checkout_txt+"</span></div>");

 

> Global.tpl : {addJsDefL name=checkout_txt}{l s='View your shopping bag'}{/addJsDefL}

 

My problem, every time I click on add to bag button, a link "View your shopping bag" appear. 

So if I click 5 times, 5 link appear…  :unsure:

 

How can I do please ?

 

Julien

 

 

why not to add it directly to .tpl file instead of adding it with jquery after "add to cart" ?

Share this post


Link to post
Share on other sites

create new div with id for example #PutMyButtonHere

<div id="PutMyButtonHere"></div> 

and add it there where you want to display this button

 

then in ajax-cart.js instead of append() use html();

then module will not append new instances of button all the time

$("#PutMyButtonHere").html("<div class='checkout_txt'><span>"+checkout_txt+"</span></div>");
  • Like 1

Share this post


Link to post
Share on other sites
  • 1 year later...
  • 1 year later...
  • 11 months later...
On 6/21/2018 at 5:58 PM, Nieveslamb said:

I have Prestashop 1.6.1.18 version, I have done all the steps and the message does not appear on my website, this is the url  https://anroshop.es 

 

Thanks!

 

On 9/30/2014 at 10:24 PM, PhpMadman said:

search for


updateLayer : function(product){

around line 716.

comment everything inside the { } (Line 717 to 731)

Nieveslamb, try this:

Instead of comment everything inside updateLayer : function(product) {

just comment where is inside and add here the code of step 2 (Skip step 2).

For me it's working really nice.

Share this post


Link to post
Share on other sites
  • 7 months later...
On 10/2/2014 at 3:15 PM, goutham7p said:

Thanks again,.. You Rock PhpMadman :)

 

I did change all tpl files where i could get add_to_cart, notification is perfectly working when i access it from Quick View or individual Product Page.

 

But i am getting NULL if i do it from category list or homepage :(

 

i am not able to find any other tpl where add_to_cart is available. If you could let me know if i am missing something, it will be really helpful

Hello do not work on the theme by défault nor on htrg00027.

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
×
×
  • Create New...

Important Information

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