Developer forum

Forum » Ecommerce - Standard features » Using customers country in cart

Using customers country in cart

Martin Nielsen
Reply

Hi DW,

When a user is logged in to the frontend of a website, and they create a cart, we have the ability to prefill their cart with informations from their AccessUser user.

I've tried almost everything now, to try and get the EcomCustomerCountry field filled with the country from my users country field, but i can't get it to work.

I have a user with these informations:

And i've create my countries like this:

When i log to my shop i'd expect my country to be German set to, but it seems to always fallback to the Country i specified on my Website, which in my case is Denmark.

Is there a secret checkbox i need to tick, or is this not supporter? How can it be done?

 

// Martin

 


Replies

 
Martin Nielsen
Reply

Okay, so i tried something else, to see if i can template the logic, but it seems my compare doesn't work.

In my order template i have this tag:

<!--@UserManagement:User.Country-->

that holds my correct country, and i thought i could just do an @if inside my Countries loop, but that didn't pan out to well.

<select name="EcomOrderCustomerCountry" id="EcomOrderCustomerCountry" >
                  <option value=""></option>
                  <!--@LoopStart(Countries)-->
                  <option value="<!--@Ecom:Country.Code2-->" selected>
                    <!--@Ecom:Country.Name--> <!--@If(UserManagement:User.Country=Ecom:Country.Code2)-->BOOM<!--@EndIf-->
                  </option>
                  <!--@LoopEnd(Countries)-->
                </select>

 

This renders BOOM no where in my list.

// Martin

 
Martin Nielsen
Reply

Any ideas on how to fix/do this? I guess i could rewrite it all to Razor, but it's a large template, and would take all day.

 
Remi Muller
Reply

Does "<!--@Parent(tag)-->" work?

It is not in the template documentation but see release notes:

http://developer.dynamicweb.com/releases/all-new-features-in-8-x/content.aspx

 

 
Martin Nielsen
Reply

Hi Remi,

Sadly this didn't work either:

<!--@If(Parent(UserManagement:User.Country)==Ecom:Country.Code2)-->BOOM<!--@EndIf-->

Even if i fix it in the template, i still have a problem with the cart showing delivery and payment methods from my default country on first visit.

 

// Martin

 
Martin Nielsen
Reply

I just looked at the method SetUserDetailsOnOrder() in DW, and it doesn't do anything in regards to the customers country and the order.

I'll describe the desired functionality and create it as a feature request.

 
Remi Muller
Reply

Ah bummer.

What you describe is desired and logic you would already expect. Guess it is a small feature to add for DW.

 

You must be logged in to post in the forum