Change Woocommerce product quantity on a link click with jQuery Change Woocommerce product quantity on a link click with jQuery wordpress wordpress

Change Woocommerce product quantity on a link click with jQuery


In Wordpress you need to replace the $ alias by jQuery. Use instead the following:

<a id="quantity150" class="button" href="#">150</a><script>jQuery( function($) {    $('#quantity150').click( function(e) {        e.preventDefault();        $('[name="quantity"]').val('150');        console.log('#quantity150 was clicked');    });});</script>

Tested an works on WooCommerce single product pages.