WooCommerce: Dynamic Pricing Plugin, How to Show the Quantity Pricing Rules

TLDR: “Show Me The Function” (get the code)

The Dynamic Pricing Plugin Is Cool

We are currently developing a website for a poultry farm that is taking their business online. Sweet! If you are wondering: Yes, the United States Postal Services does deliver live chicks. Who knew?

Anyways, our client price per chick varies with the “sex” type of the chick and the amount that is ordered. Its cheaper to order more. There is this really cool plugin from Woothemes called Dynamic Pricing Plugin that we are utilizing to create and manage all of the different pricing variations, or “pricing rules”.

The Issue

There is just one thing that is missing. As Chris Leman has pointed out in his article “The Flaw in the WooCommerce Dynamic Pricing Extension”, the Dynamic Pricing Plugin doesn’t display the pricing groups on the product page by default. What?

The total is recalculated in the cart if the quantity qualifies for an adjustment. But how are users supposed to be aware of adjustments before they click “Add to Cart”? One option would be to re-enter all of the pricing rules into the product content or description. Thats LAME. Who wants to enter information in twice? I don’t like that option. What about purchasing yet another plugin to display that information? You could. Or you can do as I did and create your own function to automatically do this for you.

How are the Pricing Rules Stored?

Basically, through an effective use of the php function var_dump and the WordPress function get_post_custom I was able to figure out how the pricing rules are stored and how they can be extracted. It turns out that the pricing rules are just added to the product as custom fields. Sweet. That makes it simple to extract the info.

The Show Pricing Rules Function

You are welcome to copy/paste this function into your own functions.php file and modify it accordingly to your own product setup.

There is no guarantee that this function will work on your site. There is simply to many ways to setup the products to account for all of them but at least this should get you started.

Note: Take a moment to briefly go over the screen shots below for a glimpse at the our particular product setup in order to get a better understanding of the function.

The Result


Our Product Setup




  • Sven

    THX a Lot !

  • Paul

    How do I set a proper if statement to hide the table if I don’t have any dynamic pricing?

  • Sol

    Hey thank you for sharing this much needed code!

    I was wondering if you are able to assist me with using your excellent snippet – but tailored to a specific user; e.g. wholesale 1 = show their respective discounts, or wholesale 2, show their respective discounts. At the moment, it shows all discounts regardless of user type.

    • bluesky120

      Hi Sol-

      Unfortunately we can not consult on specific customizations like this at this point. We do not have experience changing the output based on different accounts, so we would have to do more detailed investigation, and we don’t have the capacity right now.

      Sorry we can’t be of assistance!

      • kenkepeople


        i saw some “foreach” i’m not an php expert, but i think theres the issue…. i’m unsing this for listing wholesaler and distributor’s prices, i cant let both prices show up XD

  • Joel Machemer

    Hey there! If I wanted to customize the style of the tables that this code generates, which classes would I call out in the CSS?

  • Mister N

    Like to ask to customize if I only want to show the first pricing group on the product page.

  • Mika Jan Pedersen

    This does work for simple produce but variable product dont some error komes in line …

    Warning: Invalid argument supplied for foreach() in
    on line 27

    • Deryan Joan

      put this on wp-config:



      ini_set(‘error_reporting’, E_ALL );

      define(‘WP_DEBUG’, false);

      define(‘WP_DEBUG_LOG’, true);

      define(‘WP_DEBUG_DISPLAY’, false);

    • Danielle Gannon

      Do you know what the code was that you put in the functions.php file??? The snippet was removed here

  • Deryan Joan

    Hi, on products that has not configured the procing group i see this error:
    Warning: Invalid argument supplied for foreach() in/home/edwinliz/public_html/wp-content/themes/premium/functions.php on line456

    • Deryan Joan

      Ok, i need to put this on wp-config file to prevent that error message on product page:



      ini_set(‘error_reporting’, E_ALL );

      define(‘WP_DEBUG’, false);

      define(‘WP_DEBUG_LOG’, true);

      define(‘WP_DEBUG_DISPLAY’, false);

    • Danielle Gannon

      Do you know what the code was that you put in the functions.php file?? The snippet was removed here

  • Mika Jan Pedersen

    Hi, Thanks that worked. ;o)
    Nice job,
    I don’t know much about php coding but i think it is the heading code for variable product that conflict. (just my opservation)

    • Danielle Gannon

      Do you know what the code was that you put in the functions.php file? The snippet was removed here.

  • Shane Roberson

    Hey there! Great Fix and works perfect except I have one issue. It does not show the variation name in the tables for me. Any thoughts, suggestions?

    • Danielle Gannon

      Do you know what the code was that you put in the functions.php file? The snippet was removed here

      • Shane Roberson

        Sorry, I do not. As a result I finally just removed the code due to the issue of not being able to see the variation name which rendered it essentially useless. I scanned through some other comments on this and they referred to some similar solutions on github . . . here is the link they posted: https://gist.github.com/search?utf8=%E2%9C%93&q=WooCommerce+Dynamic+pricing&ref=searchresults


        • Danielle Gannon

          Ah man. That’s okay thanks for responding. I saw the link but the ones on there only made a table for the 1st variation and not the rest, so I’m trying to edit the code. As for the variation name, I’m hoping to figure that out once I get this working. It’s because it looks up variations by variation id and not variation name. That being said I think I could figure out how to pull the variation name from the variation id. I’m hoping to figure it out and post it here if I do. Having the original code would have helped a lot so I’m hoping someone responds and has it.

  • Marcel Westerhoff

    Hi Guillermo! Thanks for the info! Very helpful. However I think I have another issue regarding this topic.

    I have setup dynamic pricing for simple and variable products. It works great for simple products but doesn’t work 100% for variable products. It gives the right price (fixed depending on user role) in the shopping basket but doesn’t show it on the product page as it does with simple products.

    I attached images showing the product variations, dynamic pricing setup, product page of variable product (sandal) and product page of a simple product.

    Maybe you have an idea how this is possible?

    Thanks for your help! Marcel

  • John McCarthy

    Is there a reason the code is not shown?

  • Iain Faulds

    Hi Guillermo, any chance you could post the code? It doesn’t seem to show on the page.


  • SantiAzpilicueta

    Yeah, it would be great to get access to that code… Other than that, this https://kentzo.wordpress.com/2013/10/16/how-to-display-bulk-discount-table-for-dynamic-pricing/ is the best that I have found on the web, but yours seems quite nicer…

  • Tim Howe

    It looks like the github gist that was displayed in the article has been removed. Doing a quick search turns up some comparable code snippets that can be used to get a similar result as described in the article. I haven’t really tried all of them but take a look and see what works best for you.


  • Matt l

    I am looking for this code as well, but I need it to only show for the specific role if the dynamic pricing is using specific roles and fixed prices.

  • bluesky120

    Hey guys – I am not sure what happened to the Github Gist that was embedded here. I will see if I can dig it up. Another thing to keep in mind is that this code is a couple of years old now and has been modified since we published it due to updates within the WooCommerce modules, so in that sense the code was somewhat outdated before the Gist disappeared.

    • Gerald

      Hi bluesky,
      @Dynamic Pricing Plugin, How to Show the Quantity Pricing Rules

      we are facing exaclty the same challenge and it would be great if you could offer your code.

      Many tks in advance ..

  • Jason Scott McIntyre

    Does any one have this code? In desperate need. I have searched 8 hrs for a code that works. I have tried over 20 snippets.. Any update on a new file that will work with Lucas Dynamic Pricing, that displays the price table?

  • Erica Michelle

    is there any way to do this for a grouped product? We have shoes for sale and each has a number of sizes to choose from. Our customers buy them in bulk, meaning we have them as a grouped product (so they can put multiple shoes of the same size for multiple sizes in the cart all at once). We want to do dynamic pricing that allows us to have a discounted rate if they buy a certain number+ of shoes. Problem is, we’ve only figured out how to do it for each size rather than all sizes included under that product. Has anyone found a solution to this?

  • Rienk Goot
    • Nelson Nunes

      Hi, ty! You changed jQuery(document).raady(function(){ to .ready right?
      Anymore changes? Cuz It’s not working for me.

      • Rienk Goot

        It also failed with me later on. But I tried a new code thats working, add this into the functions.php.


        Somethings are translated into dutch but you can change that back, hope it works for you.

  • Rienk Goot

    I found this free plugin that shows the pricing and quantity on the product page:

    • Jean Cvllr

      The plugin provided in the link by Rienk Goot works perfectly for me ! Thanks !

  • Jon


  • Jon