Developer forum

Forum » Development » Setting deliverycountry code in OrderTemplateExtender

Setting deliverycountry code in OrderTemplateExtender

Tom Kamphuis
Reply

Hi,

Is it possible to add a country code as the deliverycountry code in an OrderTemplateExtender? I'm working on a project where logged in users can order products. They don't have the ability to alter their country of origin on the website, but they have to pay a certain fee according to the country of origin. I'm trying to tell Dynamicweb to use the countrycode like this:

this.Order.DeliveryCountry = countryCode;
this.Order.DeliveryCountryCode = countryCode;
this.Order.CustomerCountry = countryCode;
this.Order.CustomerCountryCode = countryCode;

this.Order.ShippingMethodCountryCode = countryCode;
(At first I thought I should only use the last line of code, but when that didn't work I started to use more properties. The countrycode returns an ISO standard code, e.g. for Germany it returns DE.)

Am I missing something here? The deliveryfee on the ShopingCart page is 3,50, which is the default; I would expect it to return 4,50. Does anybody got any experience in doing something like above?

Thanks!

Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
Hi Tom,

You can set the EcomOrderCustomerCountry or DeliveryCountry tag in the order template to a fixed value. E.g.:
<input type="text" style="display:none;" id="EcomOrderDeliveryCountry" 
        name="EcomOrderDeliveryCountry" value='NL' />
For a live example, check out the Shopping Cart page of the Sapph web site.

Regards,

Imar
 
Tom Kamphuis
Reply
Hi Imar,

Thanks for the reply. I'm looking for a server side solution, not a clientside solution. The webshop contains one shoppingcart page (where the deliverymethod must be set in advance, on the server), the checkout handler and a receipt page. I need the shippingcosts for a certain country and customer from the moment the shoppingcart receives products. (The management center already knows it has to use the only available shippingmethod.)

Thanks!
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
Have you tried setting the country name instead of the code for the two Countey fields? Also, are you sure the order (in session and in the database) are updated to reflect the changes?

Otherwise, I don't know how to solve this....

Imar

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer
You need to get hold of the context object:

http://developer.dynamicweb-cms.com/api/ecommerce/?Dynamicweb~Dynamicweb.eCommerce.Common.Context~Country.html

Dynamicweb.eCommerce.Common.Context.Country = New Dynamicweb.eCommerce.International.Country("DK")

Votes for this answer: 0
 
Tom Kamphuis
Reply

Setting the Country in the context object did the trick. For future use by other developers; make sure you set the Country within the TemplateExtenderRenderingState.Before state of the OrderTemplateExtender.

Thanks Nicolai and Imar for your help!


 

 

You must be logged in to post in the forum