In this code recipe, we show you how to link specific discount codes to a visitor’s country using the Local Pricing Add On.

This feature is perfect for nudging customers from different regions to sign up with a tailored discount code displayed at checkout. Plus, it ensures that people outside the specific locale cannot use a discount that isn’t available for their region.

Link Discount Codes to Specific Countries With PMPro’s Local Pricing Add On

Understanding the pmpro_local_pricing_discounted_countries Filter

The pmpro_local_pricing_discounted_countries filter allows you to link discount codes to a one or more countries.

When a visitor checks out, they will see the relevant discount code based on their geolocated country, making it a personalized experience.

If the visitor is outside this country (based on their IP address and geolocation features in the Local Pricing Add On) the discount code cannot be used.

Why Offer Discounts Based on Locations

Offering location-based discounts can help you cater to different markets and their unique economies.

For example, a discount in a region with a lower average income can make your membership more accessible.

Additionally, targeting promotions to specific countries can help you increase your market penetration and build a global customer base.

About the Code Recipe

For this code recipe, we’ll use the pmpro_local_pricing_discounted_countries filter to link discount codes to specific countries. This will help boost sign-ups by offering location-based incentives.

Local Pricing Add On at checkout where Discount Code is shown and applied at checkout because visitor is located in the linked region.

If the visitor is located outside the region that the code is assigned to, they will not be allows to use the discount code at checkout.

Local Pricing Add On at checkout where Discount Code cannot be applied because visitor is outside the region.

The Code Recipe

Adding the Recipe to Your Website

You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.

Update the array of $country_discount_codes on lines 18 to 20 with your specific country codes and corresponding discount codes to offer personalized discounts at checkout.

Free Course: Membership Site Development—The Basics

Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.

Featured Image for Membership Site Development Course: The Basics
Was this article helpful?
YesNo