In this tutorial, we’ll show you how to show product images based on the customer’s country.
Sometimes, we want to show different images for different countries. Be it for serious reasons such as the fact that in a country the way our products are presented may be sensitive or for simpler reasons such as styles and things like that.
The problem is that WooCommerce does not allow us to apply country restrictions to our products without having to use PHP snippets. Of course, we know that we don’t all have the necessary knowledge to do it, and even when we do, it’s not too much to save time and use an excellent plugin like Country Catalogs for WooCommerce.
This plugin allows us to create different country restrictions to apply them to our products. We can hide or lock products for a specific country or for several countries; we can even hide products for entire continents.
You can download the plugin here: Download Country Catalogs for WooCommerce Plugin - or - Read more
We’ll do this by creating a variation for each country and then applying a different variation image for that variation. For example, we’ll create two variations, one for El Salvador and another for the rest of the World. Just follow these simple steps.
1- Edit the plugin’s global settings
Go to WooCommerce > Advanced country.
Click on Open global settings and select the following values:
- Geolocation method: We will show a country or state selector in the header
- Restriction method: Hide product from the catalog
- Restrict by: Country and continents
- Hit Save changes.
2- Create a “Country” product attribute
Go to Products > Attributes and create an attribute called Country. You can create several countries there. In our case, we’ll create a country called El Salvador and another called World.
3- Edit the product to show different image based on the country
After creating the Country attribute, go to Products and open the product you want to show different image in different countries.
Once you open the product you’ll edit, you need to make it variable. For that, select Variable product in the Product data dropdown.
Go to the Attributes section and add the Country attribute to your product. Select El Salvador and World in the Value(s) field.
Important. You must tick the Used for variations checkbox.
a) Create the product variations you need
You need to create two product variations, one with the attribute El Salvador and one with the attribute World. Just go to the Variations section and create them.
Now it’s time to edit them individually to set the image and country restrictions.
b) Edit the first variation’s image and country restrictions
Open the El Salvador variation’s settings and upload the image to it.
Then, scroll down to the Selected countries field and select all the countries except El Salvador.
In Available in selected countries, select No. Once done that, click on Save changes.
c) Edit the second variation’s image and country restrictions
For this just open the World variation’s settings and upload the image to it.
Then, scroll down to the Selected countries field and select El Salvador. After that, select No in the Available in selected countries field. Once done that, click on Save changes.
4- Done!
After applying these changes, you’ll see that all visitors from El Salvador will just see the variation with the image you uploaded to that variation.
On the other hand, you’ll see that customers from all other countries will only see the variation created for the rest of the world and its own image.
That’s really simple. You can create different catalogs for different countries just by following these simple steps. Remember that this is just an example and that you can create as many countries as you want to create different catalogs for different countries. Which is best: You don’t need to use any PHP snippets.
You can download the plugin here: Download Country Catalogs for WooCommerce Plugin - or - Read more