Copied to clipboard

Flag this post as spam?

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


  • Jay Jayson 2 posts 72 karma points
    May 09, 2019 @ 11:15
    Jay Jayson
    0

    SetCurrentPaymentCountryRegion not updating

    Hello, I am working on a TeaCommerce project and am currently looking at setting the Payment country and Shipping country for an order within the checkout stage.

    I have tried using a couple of approaches:

    [1] from javascript using- TC.setCurrentPaymentCountryRegion({ storeId: storeId, countryId: countryId });

    [2] by posting an ajax request to a controller using- TC.SetCurrentPaymentCountryRegion(storeId, countryId);

    Immediately after calling the above methods I try to validate that the country id has been accepted by calling the appropriate TC.getCurrentPaymentCountryRegion(storeId) method.

    The result is always null, so I am wondering if there is some bug, caching issue or alternative approach I can use to set the value instead? The same happens with the Shipping country methods as well.

    Thanks, Jay

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    May 09, 2019 @ 13:36
    Matt Brailsford
    0

    Hi,

    Are you trying to set the payment country? or payment country region? They are separate things. A country region is a region within a country.

    Going by your code snippet you appear to be passing a countryId which if it's the country you are trying to set you need to be calling TC.setCurrentPaymentCountry({storeId:storeId, countryId:countryId});, but if you are trying to set the country region, you need to be passing a countryRegionId param instead of countryId within your example code snippet.

    Hope that makes sense.

    Matt

  • Jay Jayson 2 posts 72 karma points
    May 09, 2019 @ 14:28
    Jay Jayson
    0

    Hi Matt,

    Yes, I am trying to set the country and should have noted in my op that I had also tried using the methods that you suggested as well.

    I have stumbled into a solution when adding both methods into my controller and stepping through the debugger in Visual Studio.

    It seems that if I call either method twice in succession then the change is applied immediately on the current page and picked up when calling the get method. Whereas if I call either method just once then the change is applied but does not get picked up using the get method until after the page has reloaded.

    Is there a better approach I should use to set the country and commit the changes to the current page, or do you think calling the method twice is a sufficient solution (since it does appear to be working okay doing it this way)?

    Thanks, Jay

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    May 09, 2019 @ 14:47
    Matt Brailsford
    0

    Hmmm, interesting.

    Do you have a current order in progress at the time this is code is called? or is it being called before an order can exist?

    If an order exists, it could be worth grabbing the current order and seeing what has been stored against the orders payment country, to see if it's being set. Also, check your response cookies as it also stores the value in there.

    It shouldn't be necessary to call it twice so would be good to try and figure out why it needs to be (it shouldn't cause a problem to call it twice, just it's obviously wasting a bit of resources)

Please Sign in or register to post replies

Write your reply to:

Draft