Jump to content

Mark product is already in cart


theDoris

Recommended Posts

I think it is possible, you just need make some changes to the page controller and assign the product id list to Smarty variable and then in page theme file (.tpl) to use compare the product id and the list of products in cart and then mark it.

Link to comment
Share on other sites

Ok, so how I can load data via ajax after click add to cart button? I use default theme from 1.6 and I want to load this code:
 
 

{if ($cart->containsProduct($product.id_product, $product.id_product_attribute))}<div class="alert alert-info">{l s='Already in cart'}</div>{/if}
Link to comment
Share on other sites

I tried some jquery to do that, so I make that:

<div id="div1">{if $added}Added{else}not added{/if}</div>

and try few code, for example:

$(document).on('click', '.ajax_add_to_cart_button', function() {
    $("#div1").load()       /*also $("#div1").load("#div1")*/
});
$(function(){
$(document).on('click', '.ajax_add_to_cart_button', function(e) {
e.preventDefault();
$("#div1").load($(this).attr("href")); /*and this:  $("#div1").load($(this).attr("href #div1"));*/
return false
});
});

But this is not work at all for me.

 

When I try this code:

$(document).ready(function(){
$(".ajax_add_to_cart_button").click(function(){
$("#div1").html("result reloaded successfully");
});
});

It is work but no matter which product I add to cart only in first product is diplay info, also I try change html() to load() or refresh() but then is not working. What am I doing wrong?

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...