WooCommerce: Purchasing Power Parity (PPP) Discounts

Spoiler: the Business Bloomer Club (private Woo community, Woo online courses, Woo masterclasses, Woo resources) is now affordable for everyone.

In my opinion, it’s unfortunate that digital products (especially WordPress-related ones) get no price adjustment for less privileged countries.

Content should be accessible to ALL users around the world, no matter their income level. I receive dozens of emails per month from amazing people who can’t really afford a USD 397 membership because they make that amount of money in 4 months.

So, let’s change this.

Here comes Purchasing Power Parity (PPP) to the rescue.

PPP is a special metric that tells us the real “purchasing power” of a given country. Take a basket of identical goods, pay in your local currency in your own country; purchase the same items in USD in the United States. Compare that difference to the actual exchange rate. Now you really have an idea of how much a country can afford to pay for that basket of goods.

Let’s talk in plain English. Are you from India? You may get up to 75% off when PPP is applied. Are you from South Africa? Maybe a 59% discount! Are you from Argentina? 61% off on average. Are you from Norway? No discount, sorry (it seems you do better than the US). And so on…

In this post, I’ll go through a quick PPP math example to give you some context, and then I’ll tell you how I implemented PPP discounts in this same WooCommerce website.

Want to help me test the PPP discount functionality? Click here to add the GROW PASS membership to cart, worth $399, select your billing country at checkout, and leave a comment below with the discount you get, if any. It doesn’t always work – your feedback is always helpful so I can fix possible bugs!

Enjoy!

Thanks to Business Bloomer’s PPP adjustments, as of today, Afghanistan customers will get up to 75% off

Purchasing Power Parity – The Math

Example: in United States, I can buy the “WHATEVER” book for USD 10. In India, based on today’s exchange rate (USD 1 = INR 78), the price should be INR 780…. but it’s not, because India doesn’t have the same purchasing power as United States.

If the same “WHATEVER” book in India is priced at INR 300, PPP is equal to INR 300 / USD 10 = 30. You can see that there is a huge difference between the actual foreign exchange rate (78) and the calculated PPP (30). That’s to say that India, on average, can buy the same item for less dollars because it can’t afford to pay the exact converted amount.

We can now use the 2 figures to get to the following conclusion: in India this USD 10 item can be purchased in local currency for INR 300; given the current exchange rate of 78, this means that a USD 10 item can be purchased there for 300/78 = USD 3.84

In a nutshell, if India can only afford USD 3.84 out of 10, products In India sold by a US company in USD should be discounted by 61.6% to be “fair” and in line with PPP.

A USD 100 product, should be priced at USD 38.4 in India.

WooCommerce Purchasing Power Parity Implementation

I decided to detect the country directly on the Checkout page, once the Billing Country is chosen. I’m not using geolocation because it’s slower, and also because with VPN technology you may not really know where a user is from.

Here’s the PHP I use to dynamically read the billing country (2-letter code) once the checkout loads/refreshes:

/**
 * @snippet       Get Billing Country @ WooCommerce Checkout
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 9
 * @community     https://businessbloomer.com/club/
 */

add_action( 'woocommerce_checkout_update_order_review', 'bbloomer_ppp' );

function bbloomer_ppp( $post_data ) {
   parse_str( $post_data, $output );
   if ( $output['billing_country'] ) {
      $country_code_2 = $output['billing_country'];
      // THEN, DO SOMETHING WITH COUNTRY CODE
   }
}

Once I get the billing country, lots of stuff happens:

  1. I exit if the Billing Country is US, as its PPP value is 1 by definition.
  2. I make sure the cart contains the Business Bloomer Club product category, otherwise I exit.
  3. I get the country’s currency code (from WooCommerce itself).
  4. I call a free foreign exchange rate API (exchangerate.host) and get the currency exchange rate against USD.
  5. I calculate the country’s 3-letter code as it’s needed for point 6 (as opposed to the 2-letter version). This is done by calling the Worldbank API.
  6. I call a free PPP API (Worldbank) and get the country’s PPP value (calculated as the average value over the last 5 years).
  7. I calculate the discount based on PPP value (max 75%)

Here is the PHP I use to get the currency code, the exchange rate and the PPP value for a given WooCommerce billing country:

/**
 * @snippet       Get Currency, Ex Rate & PPP By Billing Country
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 9
 * @community     https://businessbloomer.com/club/
 */

// GET CURRENCY CODE
$locale_info = include WC()->plugin_path() . '/i18n/locale-info.php';	
$currency = $locale_info[$output['billing_country']]['currency_code'];

// GET EXCHANGE RATE
$req_url = 'https://api.exchangerate.host/latest/?base=USD&symbols=' . $currency;
$response_json = file_get_contents( $req_url );
$response = json_decode( $response_json );
if ( $response->success === true ) {
	$exchange_rate = $response->rates->{$currency};
}

// GET COUNTRY PPP VALUE (AVERAGE FOR PREVIOUS 5 YEARS)
$ppp_url = 'https://api.worldbank.org/v2/country/' . $country_code_3 . '/indicator/PA.NUS.PRVT.PP?date=' . date( "Y", strtotime( "-5 years" ) ) . ':' . date( "Y", strtotime( "-1 year" ) ) . '&format=json';
$ppp = json_decode( file_get_contents( $ppp_url ), true );
$values = array();
foreach ( $ppp[1] as $key => $val ) {
	if ( $val['date'] && $val['value'] ) {
		$values[$val['date']] = (float) $val['value'];
	}
}
$avg_ppp = array_sum( $values ) / count( $values );

At this stage, a checkout notification appears:

  • If no PPP value exists for that country (Worldbank doesn’t have data for every country), I invite customers to contact me because I don’t want anyone excluded from potential discounts.
  • If PPP value exists and the country has less purchasing power, I show a checkout notification with a 1% to 75% off “Apply coupon” button (on click, the checkout reloads and applies the discount).

Here’s the PHP code that displays the checkout notice when the calculated discount is between 1 and 75%:

/**
 * @snippet       Show Notice @ WooCommerce Checkout
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 9
 * @community     https://businessbloomer.com/club/
 */

$message = 'Your country is eligible for a ' . $discount . '% discount on courses! Read more about Purchasing Power Parity <a href="/woocommerce-purchasing-power-parity-discounts" target="_blank">here</a>. <a href="' . esc_url( add_query_arg( 'ppp', $discount, wc_get_checkout_url() ) ) . '" class="button wc-forward">Apply Discount</a>';

if ( ! WC()->cart->has_discount( $discount ) ) {
	wc_add_notice( $message, 'success' );
}

WooCommerce Purchasing Power Parity Coupons

Of course, I had to also look into the creation of coupon codes, because I decided to keep the PPP Discounts optional i.e. customers have to click to apply their discount.

This is a good strategy – I believe – because someone may not want to use the discount (e.g. I may be a US developer living in India, so I actually have one of the highest purchasing power values).

I therefore had to:

And that’s it.

WooCommerce Purchasing Power Parity FAQ

Rodolfo, my country gets a 49% discount and not 74% like India?

Calculations are based on public data available online, so don’t take it personally! I’ve done my best by considering the average PPP value over the last 5 years. If you still believe calculations are not fair, post a comment below and let’s talk.

Rodolfo, what about scams and bad people?

These will always be part of online commerce. I’m probably going to get some people to enter random billing countries to get a discount – but I believe their orders will fail as PayPal/Stripe won’t allow them to pay if the billing country doesn’t match. If this check fails, no problem whatsoever. These transactions will be definitely less than the amount of people all over the world that can now afford my courses.

Rodolfo, why do you apply PPP discounts to the Business Bloomer club only?

Because the other products are all below $99 and I can’t discount them. Same as WooCommerce consulting/development – unfortunately taxes here in Italy are high and I need to stick to my hourly rate.

Rodolfo, can I have the full WooCommerce PPP code?

Give me some time – this will be soon packaged into a mini-plugin!

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

4 thoughts on “WooCommerce: Purchasing Power Parity (PPP) Discounts

  1. Hi Rodolfo, as always, a great tutorial, detailed with explanations. Thank you!
    Have you maybe released the snippet for bulk coupon creation? And if not, can you maybe give an example of one coupon code setup? I assume one needs to create a coupon code for each discount percentage, in other words 75 coupons. But how do you assign them then to the relevant country code?
    Thank you!

    1. sorry, I forgot to update this article! Yes, the coupon generator snippet has been published: https://www.businessbloomer.com/woocommerce-bulk-generate-coupons/

      1. Hi Rodolfo, sorry for the repeated comment, i figured it out.
        (Country XE against US$ – PPP ) / Country XE against US$
        I am getting there! Thank you

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

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