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

the_tables

Our Product Setup

attribute_setup

variations_setup

dynamic_pricing_setup