Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan 1288 posts 3921 karma points c-trib
    Jul 16, 2013 @ 11:35
    Dan
    0

    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.

    Any points would be much appreciated, thanks!

  • Dan 1288 posts 3921 karma points c-trib
    Jul 16, 2013 @ 19:29
    Dan
    100

    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:

    CountryRegion countryRegion = TC.GetCurrentShippingCountryRegion(storeId);
    return countryRegion.RegionCode;
  • Rune Grønkjær 1372 posts 3103 karma points
    Jul 17, 2013 @ 09:36
    Rune Grønkjær
    0

    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

  • Dan 1288 posts 3921 karma points c-trib
    Jul 17, 2013 @ 09:41
    Dan
    2

    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 ;)

Please Sign in or register to post replies

Write your reply to:

Draft