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 7
 * @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 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 7
 * @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 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 7
 * @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 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 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

  • WooCommerce: Cart and Checkout on the Same Page
    This is your ultimate guide – complete with shortcodes, snippets and workarounds – to completely skip the Cart page and have both cart table and checkout form on the same (Checkout) page. But first… why’d you want to do this? Well, if you sell high ticket products (i.e. on average, you sell no more than […]
  • WooCommerce: Disable Payment Method If Product Category @ Cart
    Today we take a look at the WooCommerce Checkout and specifically at how to disable a payment gateway (e.g. PayPal) if a specific product category is in the Cart. There are two tasks to code in this case: (1) based on all the products in the Cart, calculate the list of product categories in the […]
  • WooCommerce: Add Privacy Policy Checkbox @ Checkout
    Here’s a snippet regarding the checkout page. If you’ve been affected by GDPR, you will know you now need users to give you Privacy Policy consent. Or, you might need customer to acknowledge special shipping requirements for example. So, how do we display an additional tick box on the Checkout page (together with the existing […]
  • WooCommerce: Redirect to Custom Thank you Page
    How can you redirect customers to a beautifully looking, custom, thank you page? Thankfully you can add some PHP code to your functions.php or install a simple plugin and define a redirect to a custom WordPress page (as opposed to the default order-received endpoint). This is a great way for you to add specific up-sells, […]
  • WooCommerce: Disable Payment Gateway by Country
    You might want to disable PayPal for non-local customers or enable a specific gateway for only one country… Either way, this is a very common requirement for all of those who trade internationally. Here’s a simple snippet you can further customize to achieve your objective. Simply pick the payment gateway “slug” you want to disable/enable […]

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 *