Create a Dynamic Pricing Discount table in the product page
As you know, Dynamic Pricing does not print a discount table in the single product page. This is due to the complexity of the discount rules you can create which makes impossible for the plugin to create a discount table.
But you can still do it manually. You will learn how to do this here using two free plugins with Dynamic Pricing.
Requirements
- Dynamic Pricing – Creates discount rules
- Global Content Blocks – Creates content blocks which you can print using a shortcode
- WooCommerce Custom Product Tabs Lite – Add the support for a custom tab on the single product page – See also the premium version of this plugin.
How to create the discount table
Be sure to have all the three plugins installed ad active.
The first thing you need to do is to create a discount rule for some products. In this example I’ll do it only on one product. I configured it like this:
Then you need the content block to print in the product tab.
Go to Settings > Global Content Blocks and create a new content block like this one:
After creating it, be sure to copy the shortcode of the content block from Settings > Global Content Blocks:
and go to your product admin page in Products > All Products > Edit a product.
With WooCommerce Custom Product Tabs Lite you will now have a new tab in the section Product Data named Custom Tab. This tab will allow you to create a new product tab specifying a title and the content.
In this example I used Discounts for the title, and the Global Content Blocks shortcode for the content:
Going to the product single page you will see a new tab named Discounts with the table of discounts. It should look like this (using Storefront):
WordPress does not have the table buttons in the editor, you will need to create the HTML code for the table manually. Here is the HTML used for this tutorial:
Hi Nicola. Thanks for this very useful post. It’ll be perfect for an commerce site I’m building that supports both Wholesale and Retail customers. I have a question though… suppose I want show or hide these elements based on user type? How can I hide them from retail customers and make them visible to wholesale customers?
Hi David, thanks for reading!
You can use Groups with its shortcodes. It allows you to hide/show contents based on the user role/group.
So this discount table is hard-coded, which is NOT sync with the real pricing, right? How can I do it to make it change automatically on the front-end after I change the real pricing in the back-end?
Hi John,
Yes, it is hard-coded. If you want an automatic one you can use this plugin.
any way to show the prices on product page?
i mean directly next to “put int cart” its the law in germany :/
Hi Maz,
you should use one of those plugins for the German market. They make WooCommerce reliable for the German law about eCommerce.
You can find one here: https://wordpress.org/plugins-wp/woocommerce-germanized/
There are others if you Google “WooCommerce German Market”.
Hi, the plugin Global Content Blocks is no longer available, do you have another suggestion for implementing this?
Hello Nicola,
Great way to show a price table on the product page.
Is there a piece of code to show the product name in the table. I mean, I have variable products and the price tables show, but there is no way to figure out for the customer which product the price table is for.
Kind regards,
Hi Marianne,
since the table is manually created you can simply add a title before it in the content editor.
I think that would be the best and fastest way.