Back to Forhad's Creations

Product Quantity Buttons for WooCommerce WordPress Plugin

By WP Forhad / October 15, 2024

Product Quantity Buttons is a simple yet powerful WordPress plugin that integrates with WooCommerce, allowing users to easily adjust product quantities on the single product page. The plugin adds "Increase" and "Decrease" buttons for seamless quantity management, making the shopping experience more user-friendly and intuitive.

With Product Quantity Buttons, customers can quickly change the number of products they wish to purchase without manually typing the quantity value. This enhances usability and helps boost conversions by providing a smoother and more efficient purchasing process.

Key Features

  1. Increase/Decrease Buttons: Adds visually appealing "Increase" and "Decrease" buttons on the WooCommerce single product page for easy quantity adjustments.
  2. Seamless WooCommerce Integration: Fully compatible with WooCommerce, ensuring smooth functionality across all product pages.
  3. User-friendly Design: Simple and intuitive design allows customers to change the product quantity without manual input, improving usability.
  4. Responsive for Mobile Devices: Optimized for mobile users, providing an easy-to-use interface for quantity changes on all device types.
  5. Customizable Styles: Option to customize the appearance of the quantity buttons to match the website’s theme and branding.
  6. Improved Shopping Experience: Makes it easier for customers to adjust quantities, which helps to reduce friction during the buying process and boost conversions.
  7. No Coding Required: Can be added to the product page without any coding knowledge—ideal for all WordPress users, including beginners.
  8. Lightweight Plugin: Minimal impact on website speed, ensuring that adding the quantity buttons does not affect the website performance.

Use Case

  1. E-commerce Websites: Improve the shopping experience on WooCommerce-powered online stores by allowing customers to easily adjust product quantities directly on the product page.
  2. Bulk Purchasing: Ideal for customers who want to buy multiple units of the same product, such as wholesale buyers or those purchasing items in bulk.
  3. Mobile Shopping Optimization: Enhance usability for mobile users by providing buttons for quantity adjustments, reducing the need for typing and making it more convenient for touchscreen interactions.
  4. Impulse Buying: Encourage impulse buying by making it easy for customers to add more items to their cart with just a click, boosting the average order value.
  5. User-friendly Interface: Simplify the purchasing process for users who may not be comfortable manually entering quantity values, leading to increased satisfaction and lower cart abandonment rates.

How to setup Product Quantity Plugin

Step 01: First we have to go to the WordPress dashboard.

WP Dashboard

Step 02: Then we have to click the Plugins option from the dashboard. Then we have to click  “Add New Plugin” button  , from there we have to click “Upload Plugin”. Then we have to choose the plugin from our device. Then we have to click install button. Here we can Active The Plugin or we may active it later from Plugins options

Plugin Activation

Step 03: To work with this plugin we need to install WooCommerce plugin too. After install WooCommerce option and its menus in our dashboard
like below.

Woo Commerce Options

Step 04: Then we have to add a product filling all the require fields

Product Add Options

Step 04: Then when we will go single page of a product we will see two buttons for increase and decrease like below

Single Product View Page

Use our recommended page builder plugin, FancyPost to unlock a number of powerful blocks to help you to design amazing websites!

More screenshots

Product Add Options

Live Demo

Experience the Product Quantity Buttons plugin in action with our live demo. Click the button below to see how the "Increase" and "Decrease" buttons enhance the user experience on a WooCommerce product page. Get a firsthand look at how simple and effective managing product quantities can be.

Download

Ready to improve your WooCommerce store's shopping experience? Click the button below to download the Product Quantity Buttons plugin. Install it easily on your WordPress website and start providing your customers with a seamless quantity adjustment feature today.

Please enable JavaScript in your browser to complete this form.

Developer area

The Product Quantity Buttons plugin is built to be highly customizable and extensible, allowing developers to add their own features or modify the existing ones using various hooks, filters, and custom code. Below, you'll find examples of how to extend the plugin's functionality and modify its behavior.

Example Customization Code

1. Customize Button Styling

Developers can change the style of the quantity buttons by adding their custom CSS. Here's how you can add a custom class to modify the "Increase" and "Decrease" buttons:

add_action('wp_enqueue_scripts', 'custom_pq_button_styles');
function custom_pq_button_styles() {
    wp_add_inline_style('product-quantity-buttons-style', '
        .pq-button {
            background-color: #0073aa;
            color: #ffffff;
            border: none;
            padding: 10px;
            cursor: pointer;
        }
        .pq-button:hover {
            background-color: #005f7f;
        }
    ');
}

This snippet will add custom styling to the buttons to make them match your website’s theme.

2. Customizing Button Behavior with JavaScript

Add custom JavaScript to change the functionality of the buttons, such as adding animation or changing increment behavior.

add_action('wp_footer', 'custom_pq_button_js');
function custom_pq_button_js() {
    ?>
    <script type="text/javascript">
        document.addEventListener('DOMContentLoaded', function() {
            const increaseButtons = document.querySelectorAll('.pq-increase');
            const decreaseButtons = document.querySelectorAll('.pq-decrease');

            increaseButtons.forEach(button => {
                button.addEventListener('click', () => {
                    // Add custom animation or logging here
                    console.log('Product quantity increased');
                });
            });

            decreaseButtons.forEach(button => {
                button.addEventListener('click', () => {
                    // Add custom animation or logging here
                    console.log('Product quantity decreased');
                });
            });
        });
    </script>
    <?php
}

This JavaScript example adds an event listener to the increase and decrease buttons, allowing developers to add custom behavior or animations.

3. Add Custom Hooks to Extend Functionality

The plugin includes hooks that you can use to extend its behavior. Here’s an example of how you can use these hooks to add a message when the quantity is changed:

add_action('pq_quantity_updated', 'custom_quantity_update_message', 10, 2);
function custom_quantity_update_message($product_id, $new_quantity) {
    if ($new_quantity > 5) {
        echo '<div class="notice">You have selected more than 5 items. Bulk discounts may apply!</div>';
    }
}

This code adds a custom message when the selected product quantity exceeds 5.

4. Filter to Adjust Increment Step Value

Use a filter to change the increment step value for specific products or product categories:

add_filter('pq_button_increment_step', 'custom_increment_step', 10, 2);
function custom_increment_step($step, $product) {
    if (has_term('special-category', 'product_cat', $product->get_id())) {
        $step = 2; // Set increment step to 2 for products in 'special-category'
    }
    return $step;
}

In this example, products in the "special-category" category will have their quantity increased or decreased by 2 when using the buttons.

5. Adding Quantity Buttons Using a Shortcode

If you want to add quantity buttons outside of the default WooCommerce product page, you can use a shortcode:

function pq_quantity_buttons_shortcode($atts) {
    $atts = shortcode_atts(array(
        'product_id' => 0,
    ), $atts, 'pq_quantity_buttons');

    if ($atts['product_id']) {
        // Output the quantity buttons for the specified product
        echo '<div class="pq-quantity-buttons">';
        echo '<button class="pq-decrease">-</button>';
        echo '<input type="number" value="1" min="1" max="10" />';
        echo '<button class="pq-increase">+</button>';
        echo '</div>';
    }
}
add_shortcode('pq_quantity_buttons', 'pq_quantity_buttons_shortcode');

With this shortcode, you can insert quantity buttons anywhere on your site by using [pq_quantity_buttons product_id="123"] where "123" is the ID of the product.

Associate Plugins

  • Woo Commerce By Automattic

Request for new features

We are always looking to improve! If you have any suggestions for new features or improvements to the plugin, feel free to reach out to us. Your feedback helps us make Easy Job Listing even better.(Contact form , Telegram, WhatsApp, Messenger)

Donate

If you enjoy using Product Quantity Buttons and would like to support its continued development, please consider making a donation. Your contributions will help us add more features, provide regular updates, and continue offering support to all users.

Forhad Avatar

Hossain Muhammed Forhad

Forhad Hossain is the co-founder of Pluginic. He brings a one-of-a-kind fusion of tech brilliance, business savvy and marketing mojo to the table.

Forhad has consistently spearheaded the development of innovative products like Gutenic, Editorial Rating, FancyPost and many others that have become market leaders in their respective niches.

Website Builder Front Website Builder Back

Want To Build Better WordPress Websites?
Start Here! 👇

0
1 0 Rating
2 0 Rating
3 0 Rating
4 0 Rating
5 0 Rating
Total Vote: 0

Aggregate Rating System by Editorial Rating

Leave a Reply

Your email address will not be published. Required fields are marked *