How to return Tea Commerce shipping region in base extension
Hi,
I'm using a base extension to grab variables from the Tea Commerce order and use those to obtain shipping prices from the UPS API. Everything is fine except I can't seem to return anything to do with the shipping region. Ideally I'd like the region code, but currently I just can't get it to output anything, even though the region selection is definitely being saved to the order and persists across the order process.
I've knocked up a quick base extension method to illustrate:
[RestExtensionMethod(ReturnXml = false)]
public static string OutputCountryRegion(long storeId)
{
// This doesn't output anything:
Order order = TC.GetCurrentOrder(storeId);
return order.ShipmentInformation.CountryRegionId.ToString();
// Neither does this:
CountryRegion countryRegion = TC.GetCurrentShippingCountryRegion(storeId);
return countryRegion.RegionCode;
// Neither does this:
order.Properties[ "CountryRegionId" ];
}
The storeId is definitely being passed in correctly. The base extension is working as it will output 'Hello world' when I return that. I just can't seem to get any of the shipping region data to output at all.
This turned out to be because the shipping region code wasn't being saved correctly, although billing region code was. I've written some logic to copy billing to shipping details if shipping isn't specific. Now this works:
Haha, yeah, this is like documentation of my daily struggles/breakthroughs ;) I like to post the solutions though if I find them as hopefully, like you say, it might help someone else at some point. There have been a number of times I've even come back to stuff like this and found my own answer, so it helps me at least ;)
How to return Tea Commerce shipping region in base extension
Hi,
I'm using a base extension to grab variables from the Tea Commerce order and use those to obtain shipping prices from the UPS API. Everything is fine except I can't seem to return anything to do with the shipping region. Ideally I'd like the region code, but currently I just can't get it to output anything, even though the region selection is definitely being saved to the order and persists across the order process.
I've knocked up a quick base extension method to illustrate:
The storeId is definitely being passed in correctly. The base extension is working as it will output 'Hello world' when I return that. I just can't seem to get any of the shipping region data to output at all.
Any points would be much appreciated, thanks!
This turned out to be because the shipping region code wasn't being saved correctly, although billing region code was. I've written some logic to copy billing to shipping details if shipping isn't specific. Now this works:
I just love it how you answer your own questions :)
Makes my job that much easier. Hope some other guys out there can use your posts as well.
/Rune
Haha, yeah, this is like documentation of my daily struggles/breakthroughs ;) I like to post the solutions though if I find them as hopefully, like you say, it might help someone else at some point. There have been a number of times I've even come back to stuff like this and found my own answer, so it helps me at least ;)
is working on a reply...