Developer forum

Forum » Ecommerce - Standard features » Global tags for countries and regions

Global tags for countries and regions

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

Are there global tags for ecommerce countries and regions? In almost all of our US sites we need to show a list of countries and an associated list of regions. This works fine in Ecommerce and I can easily control the available countries and regions. However, when someone signs up for an account, I would like to have the same information available. Currently we're hardcoding the countries and states in the create user template which is a) cumbersome and b) doesn't allow the shop manager to control which states are available for the user.

I was thinking about building a JSON end point that returns the data so we can retrieve it client side. I can probably add a Cart module to a page and access the country and region data from there. Alternatively, I could use the API to retrieve them.

However, I was wondering if there isn't something that is built-in already. Would it make sense to expose global loops for the countries and regions?

Thanks,

Imar


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hmmm, just tried the JSON end point route. I set up a template that returns the available countries and their regions as JSON. Works great, but only when there is an active cart, something that won't be the case when someone signs up for an account.

Any suggestions on how to handle this are highly appreciated!

Imar

 

 
Nuno Aguiar
Reply

Hi Imar,

 

We've been strugling with this in Portugal since 2007. Best approaches so far:

 - Have a Database Publishing table to output all of the information using JSON and/or load them into a javascript object

 - Set a fields in the Area Item with all of that information, and have it accessible through tags/loops

 - Use Razor to query the countries tables to avoid hardcoding the countries and JSON to get the regions

 

There are some limitaitons/drawbacks:

  • You need to create a custom user field for the country name - The standard field should be used for the country code so it interacts with the cart more accuratly
  • You need to create a custom user field for the region (either code or name/label) - The user managementa has 1 region field, but no automatic interaction with the cart
  • You will need to tweak the profile templates to accuratly display the country/region code/name

 

Best Regards,

Nuno

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Nuno,

Thanks for that; I guess I'll have to go down one of these routes.

I sure wish this was easier to so I'll post it as an enhancement request.

Imar

 

You must be logged in to post in the forum