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!
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 Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @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:
- I exit if the Billing Country is US, as its PPP value is 1 by definition.
- I make sure the cart contains the Business Bloomer Club product category, otherwise I exit.
- I get the country’s currency code (from WooCommerce itself).
- I call a free foreign exchange rate API (exchangerate.host) and get the currency exchange rate against USD.
- 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.
- I call a free PPP API (Worldbank) and get the country’s PPP value (calculated as the average value over the last 5 years).
- 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 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 Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @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:
- generate coupon codes in bulk, one for each discount amount (PHP snippet here)
- code a function to automatically apply a coupon on button click (PHP snippet coming soon)
- hide the coupon codes @ checkout, to avoid coupon sharing/abuse
And that’s it.
WooCommerce Purchasing Power Parity FAQ
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.
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.
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.
Give me some time – this will be soon packaged into a mini-plugin!
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!
sorry, I forgot to update this article! Yes, the coupon generator snippet has been published: https://www.businessbloomer.com/woocommerce-bulk-generate-coupons/
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
Cool