Hey folks.
The below code works well for adding a quantity select box to product archives and shop pages in Bricks. The only issue is, after clicking ‘add to basket’ the page gets refreshed and a visitor is sent back to the top of the page.
Does anyone know how to convert this into using AJAX ?
Any help will be massively appreciated. Here’s the code:
<?php /** * How to show quantities next to the add to cart buttons */ add_filter( 'woocommerce_loop_add_to_cart_link', 'demo_add_quanitity_to_woo_archive', 10, 2 ); function demo_add_quanitity_to_woo_archive( $html, $product ) { if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { $html = ''; $html .= woocommerce_quantity_input( array(), $product, false ); $html .= '' . esc_html( $product->add_to_cart_text() ) . ''; $html .= ''; } return $html; } ?>