HomeHome Product Discus... Product Discus...RazorCartRazorCartUpdating a quantity in the detail page so it goes on "Add to Cart"Updating a quantity in the detail page so it goes on "Add to Cart"
Previous
 
Next
New Post
12/20/2018 7:14 PM
 
I have a particularly nasty programming problem that I can probably get past if I could through javascript force a value into the detail page quantity text field and then use js to click the "Add To Cart" button.

I've placed an id on the quantity input field and when you clikc a new button it does update the value on screen. But when I click Add to Cart the value is still what it was before the update. If it was 1 as a default and the JavaScript c hanged it to 5 (or -1) and I click the Add to Cart button manually, the product gets added but the quantity is 1.

Is there a way to fix this? The input field shows a 5, but sends a 1.

Thanks,
G
 
New Post
12/20/2018 8:55 PM
 
Here's the javascript I'm using. I've tried it both with standard DOM javascript and JQuery, both do the same thing. The number on the page updates but when you click add to cart the number isn't there. Manually updating the number changes it just fine,

  (for some reason the textarea won't let me paaste the code)

I get a var with javascript.document.GetElement and do a (var).value = 5 (or "5" or '5')

or I get a JQuery selector and do a (selector).val(5) (or "5" or '5')

The value on screen updates but when I click on add to cart, the pre-javascript/jquery value is what gets sent to the shopping cart.
 
New Post
12/31/2018 1:55 PM
 
George,

Changing the value via $(selector).val(value) does not trigger the change event, it only updates the textbox, please try: $(selector).val(value).change(); or $(selector).val(value).trigger('change');

https://api.jquery.com/change/
http://api.jquery.com/trigger/

Regards,
Wael
 
Previous
 
Next
HomeHome Product Discus... Product Discus...RazorCartRazorCartUpdating a quantity in the detail page so it goes on "Add to Cart"Updating a quantity in the detail page so it goes on "Add to Cart"