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
    May 13, 2013 @ 18:39
    Dan
    0

    Country regions

    Hi,

    I have a requirement to add 'state' to the shipping and billing details collected in a TeaCommerce 2.0.0 installation.  By default the starter kit doesn't give this field, but before I add it in I remember something about 'regions' being built into TeaCommerce 2.  Would regions do what I need (literally just to allow the customer to supply their US state)?  If so, where do I add these and how to I enable this functionality?

    Thanks

  • Rune Grønkjær 1372 posts 3103 karma points
    May 14, 2013 @ 08:15
    Rune Grønkjær
    100

    Hi Dan,

    Yes, regions and states are one and the same. In the Tea Commerce section under countries you can right click a country and add states to that country.

    The Tea Commerce starter kit supports this in a simple variant by default, but doesn't use it. All you need to do is to display the regions to the customer, so he can select one, and then use the one of the API's to add the information to the order: http://documentation.teacommerce.net/

    It's pretty simple, but feel free to ask again if you run into problems.

    /Rune

  • Dan 1288 posts 3921 karma points c-trib
    May 14, 2013 @ 12:00
    Dan
    0

    Thanks Rune.  You may need to talk me through in a little more detail if that's okay though.

    I've added the states as nodes under the country node in the Tea Commerce section.  I have not added 'Region code' or selected default shipping or payment methods for each state - should I?  (At the moment it just looks like the graphic below.)

    Now, when I add some items to cart on the website and I go to check out, I notice that there is a region selector which automatically appears in the customer info forms.  Great.  So it seems like I don't need to do anything there right?  However, when I proceed I get a 500 internal server error when I submit my payment and shipping options on step 3 of the cart.  It worked before without the regions, now it errors.

    The system I'm using is based on the starter kit.  So do I need to do some work to fully implement the region selector?  I'm just confused that it's kind of half working.

    Thanks

  • Rune Grønkjær 1372 posts 3103 karma points
    May 14, 2013 @ 13:30
    Rune Grønkjær
    0

    Thats no problem at all.

    You don't need to fill out all the fields if you don't need them yourself. Shipping and payment methods will just default to the one on the parent country.

    Can you give me some more information about the 500 error? Maybe what post data you are sending along. You might need to filter the list of states if you have more than one country with states. Maybe you are trying to select a state that does not belong to the state. (Can't see why that would throw an error). Read about the state part of the html API here: http://documentation.teacommerce.net/html-api/country/setcurrentpaymentcountry/

    Maybe try and set the state using the javascript API: http://documentation.teacommerce.net/javascript-api/country-region/setcurrentpaymentcountryregion/
    That way you can see if that part works. Also maybe try and remove some other calls from the html API call, to maybe find the part that is wrong.

    /Rune

  • Dan 1288 posts 3921 karma points c-trib
    May 14, 2013 @ 14:40
    Dan
    0

    Thanks Rune.

    Could you confirm that there's a bug in the starter kit whereby the razor macro which collects the customer address details has two region drop-down selects (one for payment region and the other for shipping region) but both HTML select tags have the same name attribute 'paymentCountryRegion'.  One should be 'paymentCountryRegion' and the other 'shippingCountryRegion', right?

  • Rune Grønkjær 1372 posts 3103 karma points
    May 14, 2013 @ 14:52
    Rune Grønkjær
    0

    Yes, I believe you're right. Good eyes. Yes the last of them should be named "shippingCountryRegion". I will need to fix that.

    /Rune

  • Dan 1288 posts 3921 karma points c-trib
    May 14, 2013 @ 14:58
    Dan
    0

    Do I need to add the shipping and payment country regions to the hidden 'propertykeys' form input?  Bearing in mind that the form contains these inputs:

    <input name="SetCurrentPaymentCountry" type="hidden" value="countryId : paymentCountry" />
    <input name="SetCurrentPaymentCountryRegion" type="hidden" value="countryRegionId : paymentCountryRegion" /> <input name="SetCurrentShippingCountry" type="hidden" value="countryId : shippingCountry" /> <input name="SetCurrentShippingCountryRegion" type="hidden" value="countryRegionId : shippingCountryRegion" />
  • Rune Grønkjær 1372 posts 3103 karma points
    May 14, 2013 @ 15:03
    Rune Grønkjær
    0

    They should just be as is and you should fix the bug you mentioned before. Then it should work. And if not, something else is not working or set up properly.

    /Rune

  • Dan 1288 posts 3921 karma points c-trib
    May 14, 2013 @ 15:29
    Dan
    0

    Yeah, I fixed that name bug and the form seems to be posting what it should be, but it's still not working.  It might be something to do with the value from the billing region selector not being used as the shipping region selector if no shipping details are supplied, as when both are supplied it gets further.  I'm looking around for the logic which says 'if there are no shipping details entered use billing details as shipping details' but I can't see this logic - do you know where it is?

    Thanks for your help on this - it's proving difficult to debug!

  • Rune Grønkjær 1372 posts 3103 karma points
    May 14, 2013 @ 15:35
    Rune Grønkjær
    0

    It does seem to work in the starter kit. Take a look now. I have just added a state to jamaica.

    /Rune

  • Dan 1288 posts 3921 karma points c-trib
    May 14, 2013 @ 15:38
    Dan
    0

    I've tried that on the starter kit but although it doesn't error, if you go back from cart step 3 to 2 it doesn't 'remember' the region you selected.  Is it definitely being saved?

  • Rune Grønkjær 1372 posts 3103 karma points
    May 14, 2013 @ 15:46
    Rune Grønkjær
    0

    It's being saved alright. You can see that on step 4 where "test" is displayed. So maybe there's an bug in the select "selected" function.

    You can always check the information on your order using your browsers console and the getCurrentOrder JavaScript method. Just to verify that it is saved.

    Are you still getting a 500 error?

    /Rune

  • Dan 1288 posts 3921 karma points c-trib
    May 14, 2013 @ 16:36
    Dan
    0

    I'm not getting the 500 error (I cleared cookies and client-side cache since adding the regions and that sorted it) but I still have a couple of problems.  Firstly, when I complete all customer details and proceed to step 3 there are no payment options or shipping options available (these are configured and were working prior to adding regions - possibly something to do with my custom shipping calculator!) but as well I notice that when I go back to step 2 there's a console error:

    Uncaught TypeError: Cannot read property 'orderLines' of undefined ecommerce.js:329
    getOrderTotalQuantity ecommerce.js:329
    updateMiniCart ecommerce.js:86
    (anonymous function) ecommerce.js:14
    (anonymous function)

    I can't really see why this error is happening as it doesn't happen on any of the other cart steps - only the customer info one.  I can't see why the javascript 'cart' object would be undefined on this page alone but defined on other pages.  Any ideas?

  • Dan 1288 posts 3921 karma points c-trib
    May 14, 2013 @ 17:03
    Dan
    0

    This is a separate thing, but I've found that the issue with the regions not being 'remembered' in the customer details forms is because the javascript function initCountryRegionSelect(); is resetting the options on page load.  I'm yet to find a proper work-around (currently just disabling this function call on load works as I only have one country option and one set of regions) as my main concern is the shipping/payment options not showing up, but thought I'd note it in case anyone else has this trouble.

  • Dan 1288 posts 3921 karma points c-trib
    May 14, 2013 @ 17:24
    Dan
    0

    Sorted.  The payment and shipping methods need to be explicitly selected as being available for each region added, in the Tea Commerce settings.

  • Rune Grønkjær 1372 posts 3103 karma points
    May 15, 2013 @ 08:14
    Rune Grønkjær
    0

    Aah. Of cause. Didn't know that that was the problem.

    Actually that sounds like a bug to me. The regions should inherit that information from the parent country if they don't have the information themselves.

    We will have a look at that and fix it.

    Thanks for you effort Dan.

    /Rune

Please Sign in or register to post replies

Write your reply to:

Draft