Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Display the Quantity Discount Table on the WooCommerce Product Page?

Showcasing bulk discounts table on the product page can help customers quickly see how the unit price decreases with larger quantities. This customization helps them to clearly identify the different pricing and discount tiers that will help wholesale customers to buy more products to reach the next discount threshold.

// Function to output the styled quantity discount table
function ts_display_quantity_discount_table() {
    // Define the discount tiers
    $discount_tiers = array(
        array('quantity' => 4, 'percent' => 0),
        array('quantity' => 10, 'percent' => 5),
        array('quantity' => 15, 'percent' => 10),
        array('quantity' => 20, 'percent' => 15),
        array('quantity' => 25, 'percent' => 20),
        array('quantity' => 30, 'percent' => 25),
    );

    // Output the styled quantity discount table
    echo '<div style="margin-top: 20px;">';
   
    echo '<table style="width: 100%; border-collapse: collapse;">';
    echo '<thead><tr><th style="padding: 10px; text-align: center; border: 1px solid #ddd; background-color: #f2f2f2;">Quantity</th><th style="padding: 10px; text-align: center; border: 1px solid #ddd; background-color: #f2f2f2;">Discount</th></tr></thead>';
    echo '<tbody>';
    
    foreach ($discount_tiers as $tier) {
        echo '<tr>';
        echo '<td style="padding: 10px; text-align: center; border: 1px solid #ddd; background-color: #fff;">' . $tier['quantity'] . '</td>';
        echo '<td style="padding: 10px; text-align: center; border: 1px solid #ddd; background-color: #fff;">' . $tier['percent'] . '%</td>';
        echo '</tr>';
    }

    echo '</tbody>';
    echo '</table>';
    echo '</div>';
}

// Hook to display the styled quantity discount table after the product price
add_action('woocommerce_single_product_summary', 'ts_display_quantity_discount_table', 11);

Output

The output shows that the quantity discount table of different tiers is displayed on the individual product pages of all products.

How to Display the Quantity Discount Table on the WooCommerce Product Page? - Tyche Softwares

Let’s take a look at how the product page appeared before applying the code.

How to Display the Quantity Discount Table on the WooCommerce Product Page? - Tyche Softwares

The above customization is to display the discount tiers on the individual product page. Look into this guide on how to add dynamic bulk WooCommerce discount tiers based on quantity that will help you to implement the functionality of discount tiers on the cart page.

Browse more in: Code Snippets, Uncategorized, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x