alano3city Posted September 21, 2015 Share Posted September 21, 2015 (edited) hi everyone, just a simple question. how can i apply class "added" to button add to cart on click? (ps. 1.6) i try this snippet in global.js but cant get it work... $(document).on('click', '.ajax_add_to_cart_button', function(){ $(this).removeClass('added'); $(this).addClass('added'); }); Edited September 21, 2015 by alano3city (see edit history) Link to comment Share on other sites More sharing options...
gabdara Posted September 21, 2015 Share Posted September 21, 2015 The click event of add to cart button is handled here: https://github.com/PrestaShop/PrestaShop/blob/1.6.1.x/themes/default-bootstrap/js/modules/blockcart/ajax-cart.js#L131 Link to comment Share on other sites More sharing options...
alano3city Posted September 21, 2015 Author Share Posted September 21, 2015 hmm i placed this: $(this).addClass('added'); before line 132 and still doesnt work Link to comment Share on other sites More sharing options...
gabdara Posted September 21, 2015 Share Posted September 21, 2015 I've just tested the above in localhost and I see the class being added. Link to comment Share on other sites More sharing options...
alano3city Posted September 22, 2015 Author Share Posted September 22, 2015 hmm this seems to work only when my ajax cart is turned off Link to comment Share on other sites More sharing options...
alano3city Posted September 22, 2015 Author Share Posted September 22, 2015 (edited) I see that this works everywhere, but doesnt want to work only if i click this button for example: $(document).on('click', 'input', function(e){ $('.ajax_add_to_cart_button').addClass('added'); }); when i click on any input it adds this class to the button, but on the button add to cart itself, does not Edited September 22, 2015 by alano3city (see edit history) Link to comment Share on other sites More sharing options...
Ray UK Posted September 22, 2015 Share Posted September 22, 2015 This would be a good feature to have... maybe in the PS 1.7 ? but I think it would need to check the current cart for the products, then we could overlay, for example, "3 of these in cart" on that product. Just adding the class via ajax, surely you would loose that class if you change category and came back to the same category.. or refresh the page ? Link to comment Share on other sites More sharing options...
alano3city Posted September 23, 2015 Author Share Posted September 23, 2015 this would be awesome for sure! @gabdara: it turned out that it didnt work because i had quantity module installed and the button was refreshed via this module so i added this code to the module inside. Thank you guys. 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