ruisonika Posted February 27, 2017 Share Posted February 27, 2017 hello guys, i'm having a bunch of trouble to find something about this: 1- i've add quantities input field in homepage and when i trigger the cart buy button i want to add those quantities of the input field...i've tried so many things but ... without any sucess!!!can someone give me a hand? ___________________________________ PrestaShop version: 1.6.1.7 Shop URL: http://nnn.acidados.net/ Current theme in use: pf_golmart ---------------------------------------------many many thanks to all the nice developers that will try to help me Rui Link to comment Share on other sites More sharing options...
joseantgv Posted February 27, 2017 Share Posted February 27, 2017 hello guys, i'm having a bunch of trouble to find something about this: 1- i've add quantities input field in homepage and when i trigger the cart buy button i want to add those quantities of the input field... i've tried so many things but ... without any sucess!!! can someone give me a hand? ___________________________________ PrestaShop version: 1.6.1.7 Shop URL: http://nnn.acidados.net/ Current theme in use: pf_golmart --------------------------------------------- many many thanks to all the nice developers that will try to help me Rui Check around line 131 from /themes/pf_golmart/js/modules/blockcart/ajax-cart.js. 1 Link to comment Share on other sites More sharing options...
ruisonika Posted February 27, 2017 Author Share Posted February 27, 2017 Check around line 131 from /themes/pf_golmart/js/modules/blockcart/ajax-cart.js. thanks joseantgv that's the file i've been working //for every 'add' buttons... $(document).off('click', '.ajax_add_to_cart_button').on('click', '.ajax_add_to_cart_button', function(e){ e.preventDefault(); var idProduct = parseInt($(this).data('id-product')); var idProductAttribute = parseInt($(this).data('id-product-attribute')); //var minimalQuantity = parseInt($(this).data('minimal_quantity')); var minimalQuantity = $('#quantity_wanted_').val(); //with this line i almost ready to go, but the catch is that the quantity introduced in the first input field stays the same to the others fields, from a different product, how can i say that this line is for that expecific id product? if (!minimalQuantity) minimalQuantity = 1; if ($(this).prop('disabled') != 'disabled') ajaxCart.add(idProduct, idProductAttribute, false, this, minimalQuantity); }); Link to comment Share on other sites More sharing options...
joseantgv Posted February 28, 2017 Share Posted February 28, 2017 thanks joseantgv that's the file i've been working //for every 'add' buttons... $(document).off('click', '.ajax_add_to_cart_button').on('click', '.ajax_add_to_cart_button', function(e){ e.preventDefault(); var idProduct = parseInt($(this).data('id-product')); var idProductAttribute = parseInt($(this).data('id-product-attribute')); //var minimalQuantity = parseInt($(this).data('minimal_quantity')); var minimalQuantity = $('#quantity_wanted_').val(); //with this line i almost ready to go, but the catch is that the quantity introduced in the first input field stays the same to the others fields, from a different product, how can i say that this line is for that expecific id product? if (!minimalQuantity) minimalQuantity = 1; if ($(this).prop('disabled') != 'disabled') ajaxCart.add(idProduct, idProductAttribute, false, this, minimalQuantity); }); You need to define a different ID for each field and get the value of this field or change the selector to find the nearest input to the add to cart button that you click. 1 Link to comment Share on other sites More sharing options...
ruisonika Posted February 28, 2017 Author Share Posted February 28, 2017 (edited) You need to define a different ID for each field and get the value of this field or change the selector to find the nearest input to the add to cart button that you click. "define a different ID for each field and get the value of this field" yes the ID is here in the html file. id="quantity_wanted_{$product.id_product|intval}" so in ajax-cart.js how can i get the value of that? thanks for any help Edited February 28, 2017 by ruisonika (see edit history) Link to comment Share on other sites More sharing options...
joseantgv Posted February 28, 2017 Share Posted February 28, 2017 (edited) "define a different ID for each field and get the value of this field" yes the ID is here in the html file. id="quantity_wanted_{$product.id_product|intval}" so in ajax-cart.js how can i get the value of that? thanks for any help So you should have here the product ID: var idProduct = parseInt($(this).data('id-product')); Concatenate with the button selector: var minimalQuantity = $('#quantity_wanted_'+idProduct).val(); Be careful with the product attribute ID, I don't know if you are using it. Edited February 28, 2017 by joseantgv (see edit history) 1 Link to comment Share on other sites More sharing options...
ruisonika Posted February 28, 2017 Author Share Posted February 28, 2017 So you should have here the product ID: var idProduct = parseInt($(this).data('id-product')); Concatenate with the button selector: var minimalQuantity = $('#quantity_wanted_'+idProduct).val(); Be careful with the product attribute ID, I don't know if you are using it. MANY THANKS FOR THE HELP IT WORKS 1 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