WooCommerce: Purchasing Power Parity (PPP) Discounts

Since… today, Business Bloomer online courses are affordable for everyone.

It’s unfortunate that digital products (such as our WooCommerce online courses) are priced in USD dollars but there is no adjustment for less privileged countries.

This is a pity because content should be accessible to ALL WooCommerce developers 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 course because they make that amount of money in 4 months if they’re lucky.

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 our online courses. 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 which is currently in beta? Add a course to cart e.g. CustomizeWoo PRO, select your billing country at checkout, and leave a comment below with the discount you got, if any.

Enjoy!

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

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 course, 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        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

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 make sure country is not US, as its PPP value is 1 by definition.
  2. I make sure the cart contains the “online-courses” 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        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

// 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 PPP is not null and discount is between 1 and 75%:

/**
 * @snippet       Show Notice @ WooCommerce Checkout
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

$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:

  • generate coupon codes in bulk, one for each discount amount (PHP snippet coming soon)
  • automatically apply a coupon on “Apply coupon” button click (PHP snippet coming soon)
  • hide the coupon codes @ checkout, to avoid coupon sharing/abuse

And this is it.

WooCommerce PPP is now in beta, already running on Business Bloomer checkout page, and you can test it out by adding a course to cart (e.g. here’s a direct link to add CustomizeWoo PRO to cart), selecting a billing country, and reading the checkout notification with the discount amount.

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. We’re still in beta.

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 recognize that country. 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 online courses only?

Because the other products/subscriptions 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 a few days/weeks. This will be soon packaged into a mini-plugin, so that you can apply the same to your own WooCommerce store.

Rodolfo, I am an existing student and X months ago I paid full USD price…

I know your pain, but do remember that you got lifetime access to videos as well as lifetime support for WooCommerce matter. If this is still not sufficient, I understand. Get in touch and I’ll see if I can help.

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

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.

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. 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 BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published.