From the past couple of months we have been working on several e-Commerce projects and as we have been already using WordPress for websites & blogs, it was an obvious choice for us to go with something which was as simple & flexible as WordPress for building an online store too.
Majority of our clients being from India came up to us asking for a solution to sell WooCommerce products in two separate prices Indian rupee & US dollar. The catch here is, it won’t be based on exchange rates rather store will have fixed separate price for both the countries. Now most of the payment gateways our clients come up with don’t have support for international currency & for woocommerce technically we can have only one base currency. So if we have rupee set as the base currency we won’t be able to configure or Paypal as it doesn’t support Indian currency. If we have dollar as default currency Indian payment gateways won’t accept it. All we needed was to have Instamojo as payment gateway for Indian customers and PayPal for rest of the world. PayPal by default hides when currency is not supported by that was not the case with instamojo. So to make things work we needed combination of PayPal and Instamojo.
Here’s how we did it…
After several hours of digging into wordpress plugin repository and woocommerce documentation we found some pointers that would help us.
- Setting country specific price which can be achieved via WooCommerce price by country
- Set dollar ($) as base currency in WooCommerce
- Using WooCommerce filters to unset payment gateway based on user location
Let’s get the ball rolling…
Step 1
Install plugin WooCommerce Price Based on Country by your preferred method (Plugin Interface, Zip file or FTP)
Step 2
Configure installed plugin to have country specific pricing. Once plugin is installed you can find new tab “Price Based On Country” in woocommerce settings. Plugin lets you define price for as many countries you want. If price for specific country is not defined we can either have the exchange price calculated based on base price or have regular price of product as fallback which will be in base currency. Add price of india and save.
Step 3
Set us dollar as base currency under woocommerce settings
Step 4
Add the following code to you functions.php to remove instamojo for non Indian customers
Step 5
Add new product under woocommerce now you will have addition price fields one for india and one for rest of the world.
So this is how we achieved the solution. If ever you run into any problems, or need to extend your online store features, there will always be someone to turn to. So what are you waiting for?