theDoris Posted January 20, 2017 Share Posted January 20, 2017 (edited) Hi,When customer add product to cart is there any posibility to mark it in product list on that product? Edited January 22, 2017 by theDoris (see edit history) Link to comment Share on other sites More sharing options...
Kinro Posted January 20, 2017 Share Posted January 20, 2017 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 More sharing options...
shokinro Posted January 20, 2017 Share Posted January 20, 2017 it seems that I used my "addons marketplace" account (not forum account) replied the message Link to comment Share on other sites More sharing options...
theDoris Posted January 20, 2017 Author Share Posted January 20, 2017 (edited) Tkanks for reply, i will try that but i think it will be visible only after page refresh so there will be need some ajax to make it in live :/ Edited January 22, 2017 by theDoris (see edit history) Link to comment Share on other sites More sharing options...
theDoris Posted January 20, 2017 Author Share Posted January 20, 2017 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 More sharing options...
shokinro Posted January 20, 2017 Share Posted January 20, 2017 you may need to look into the module blockcart, check related javascript and see where you can override the add to cart button event handler and then mark the product just added without refreshing the page. Link to comment Share on other sites More sharing options...
theDoris Posted January 22, 2017 Author Share Posted January 22, 2017 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 More sharing options...
shokinro Posted January 22, 2017 Share Posted January 22, 2017 in shopping cart, you should be able to find out which product is last added. there is a method call in Cart class. $cart->getLastProduct(); you consider to use that to get last added product ID Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now