Show based on Country Code

Hi,

I was wondering if someone would mind having a look at a Conditional setup I have on our site and let me know if they think its sound or not?

I am using a plugin called Geolocation IP Detection to detect what country a visitor is from. The plugin works well and produces a Country code from a shortcode.

I want to show prices in AUD$ for AU & NZ country codes, and USD$ for everyone else.

I created a custom Post in ACF and added a text field called User Country Code where I set the default value to the ShortCode given by Geolocation IP Detection.

I then created a single custom post and set all my pricing on a condition to that post.

My concern is: will the post refresh from User to User so the Shortcode always shows the current User’s Country Code? If not is there a better way to do it?

Thanks Darren.

Hi Darren,

Thanks for reaching out.
I am not sure what exactly you are trying to do here. The shortcode for said plugin should show the country code for each user, which can be compared. If that is not the case, I would request that you elaborate on it a bit more to understand.

Thanks

Hi Tristup,

Yes the shortcode works fine and shows the country Code of the visitor. I am wanting to then show them prices based on where they are from. So if they are from Australia (AU) then I want to show the pricing we have for them.

Regards,
darren.

Hi Darren,

In that case, you can add different sections with different prices and set conditions for specific country codes.

image

Hope it helps.
Thanks

Hi Tristup,

Yes, that is what I’ve done. However I’m unsure how to reference the country code in the conditions. Do I add the shortcode that gives the country code to the section then hide it?

Thanks,
Darren.

Hi Darren,

You can add the Dynamic Content i.e. {{dc:acf:field field="country}} with the key and check with the currency, like AU.

Hope it helps.
Thanks

Hi Tristup,

Yes so using ACF - that is what I am currently doing, however the results are intermittent. Sometimes it shows correctly, sometimes not after refreshing the page.

Regards,
darren.

Hi darren,

In that case, I would suggest you add the Dynamic Content tag to a Text element and check what the value is while showing the wrong output. That way, you can trace exactly what was happening at that time.

Hope it helps.
Thanks

Hi Tristup,

Yes, I’ve already done this - all instances on the pages where it says AU or US are dynamic content. It will sometimes show US$ for me, with my IP in Australia, then switch the next day to show AU$. There doesn’t seem to be any consistency.

Regards,
Darren.

Hi Darren,

I would suggest you please provide login credentials for your site in a secure note to examine it further, including:

– WordPress Site URL & Login URL
– WordPress Admin username/password
– Specific page where you have integrated it.

To create a secure note, click the key icon underneath any of your posts.

Thanks

Hey Darren,

What you are doing will not work. Just insert the shortcode directly into the condition like this:

Kindly let us know how it goes.

Hey Ruenel,

Wow, I was so fixated on ACF I missed the obvious solution…THANK YOU!

Upon checking with my hosting company, the program executions had sky rocketed up to around 12K per hour. I think this occured when I set the consumers on those pages to “Rewind”. Could that have been the reason?

I’ll monitor the CPU useage and program executions over the next few hours and see if it drops…

THanks again,
Darren.

Hey Darren,

The spike of the execution could be from a plugin or that of the shortcode. I am not sure though.

Cheers.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.