Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More โImprove the shopping experience on your WooCommerce store by adding dynamic plus (+) and minus (-) buttons to the product quantity input. Using a combination of PHP action hooks like woocommerce_before_add_to_cart_quantity and a small jQuery script, you can enable a mobile-friendly way for customers to adjust item counts. This UI enhancement makes it easier for users to select the right quantity, potentially increasing the average order value by simplifying the interaction.
Want to simplify product quantity input for your WooCommerce store? Add dynamic "+" and "−" buttons to the quantity selector using action hooks and JavaScript.
Navigate to your theme's functions.php and include the code below:
// Insert plus and minus buttons around quantity input
function woocommerce_quantity_buttons() {
echo '<div class="quantity-buttons">';
echo '<span class="minus">-</span>';
echo '<input type="number" step="1" min="1" max="" name="quantity" value="1" class="input-text qty text" size="4" />';
echo '<span class="plus">+</span>';
echo '</div>';
}
add_action('woocommerce_before_add_to_cart_quantity', 'woocommerce_quantity_buttons', 10);
// Load the JS file
function load_quantity_js() {
wp_enqueue_script('quantity-script', get_stylesheet_directory_uri() . '/js/custom-scripts.js', array('jquery'), '1.0', true);
}
add_action('wp_enqueue_scripts', 'load_quantity_js');
Create a new file at /js/custom-scripts.js inside your theme and paste this:
jQuery(document).ready(function($) {
$(document).on('click', '.plus, .minus', function() {
var $input = $(this).siblings('input[type="number"]');
var current = parseFloat($input.val());
var min = parseFloat($input.attr('min'));
var max = parseFloat($input.attr('max'));
var step = parseFloat($input.attr('step'));
if ($(this).hasClass('plus')) {
if (current < max || isNaN(max)) { $input.val(current + step); } } else { if (current > min) {
$input.val(current - step);
}
}
$input.change();
});
});
This tweak enhances your product pages with user-friendly quantity control using "+" and "−" buttons. Adjust paths if needed based on your theme’s folder structure. 
Search our archives or reach out to our team for solutions and expert advice.