Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 119588

splashingpixels.com on "[Plugin: WooCommerce - excelling eCommerce] Adding Quantity to archive page add to cart"

$
0
0

Here are some reference for you:

woocommerce-ajax.php line 181 function woocommerce_ajax_add_to_cart()
add-to-cart.js line 4 $('.add_to_cart_button')

So basically you're wanting to add the quantity field and use the add to cart JS to pull the quantity value and pass that to the ajax action. In the code you can see ONLY the id is passed...you need to add the quantity and then in the woocommerce_ajax_add_to_cart function, get the quantity and pass it to the class method add_to_cart..you can even see it is default to "1" which means it is currently only adding 1 quantity...so instead, you pass in the value you got from the ajax...

That is the bulk of it...but don't forget to sanitize your values as you don't want to accept any code passed in...use absint() function to restrict it to integer values.

Perhaps I can write a plugin for this so everyone can use it...Hmmm..


Viewing all articles
Browse latest Browse all 119588

Trending Articles