Copied to clipboard

Flag this post as spam?

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


  • Tommy Pedersen 15 posts 65 karma points
    Aug 27, 2013 @ 09:57
    Tommy Pedersen
    0

    multilanguage/currency problem

    Hello there

    im trying to setup a tea commerce solution using the tea commerce starter kit v3.2.0, my customer wants to be able to sell in 3 countries UK, DA, FR my issue is i cant seem to work around how the best practise is for handling currency, it seems to use the default currency selected in the shop selected in the store selection.

    the site is set so if the user goes to example mystoreexample.dk it redirects to mystoreexample.com/da and so on with all countries. but if im in the DA section it should show prices in danish krones all over the site and use danish vat and if the user is on the mystoreexample.com/fr shop it should show all prices in euro. i have created all vats and currencys in the store section of the tea commerce section but how to let it be used like i want instead of having EURO as currency for all countries? any way to do it in tea commerce or does any one have a solution for it?

  • Rune Grønkjær 1372 posts 3103 karma points
    Aug 28, 2013 @ 09:28
    Rune Grønkjær
    0

    Hi Tommy,

    You should set up the countries in the Tea Commerce settings and on each country you should se a default currency.

    On each currency you need to chose which countries that currency should be available in. If you only set DKK to available in Denmark, franc's in france and so on, you can now change the country and the currency will change with it.

    Now set up a small razor macro that will change the country automatically on every page load depending on where the user is on your site. Remember this must happen in the

    ANOTHER solution, is to set up the razor macro to change the currency on each page load. In that case you will probably need to set up the currencies to be available in all countries, as you might give the customer the opportunity to change country later in the cart.

    Remember that countries and Umbraco languages are two completely different things.

    /Rune

  • Tommy Pedersen 15 posts 65 karma points
    Aug 29, 2013 @ 09:45
    Tommy Pedersen
    0

    Hi Rune

    I have set up countris in the TC settings and set default currency, and made the different currency available for the countries they should be available in, havent made macro yet but when i change the country on the site currency still dosn't change, will it first start to change when i have embedded a macro that change the currency on each page load?

  • Anders Burla 2560 posts 8256 karma points
    Aug 29, 2013 @ 09:53
    Anders Burla
    0

    Could you send a screenshot of your setup of your currencies - especially the "Available in" tab. If your currency is only allowed in lets say Denmark and you have a USD currency that is only allowed in United States. Then when you change your country from Denmark to United States - your currency for your order should change as well.

    Kind regards
    Anders

  • Tommy Pedersen 15 posts 65 karma points
    Aug 29, 2013 @ 10:50
    Tommy Pedersen
    0

    thats how it is setup inside TC settings.

    heres and overall img of all currencies

  • Anders Burla 2560 posts 8256 karma points
    Aug 29, 2013 @ 11:06
    Anders Burla
    0

    That looks right. DO you use the Razor TC class to change the country?

  • Tommy Pedersen 15 posts 65 karma points
    Aug 29, 2013 @ 11:11
    Tommy Pedersen
    0

    im not sure how/where to set that up, if that isnt in the starter kit.

  • Anders Burla 2560 posts 8256 karma points
    Aug 29, 2013 @ 11:12
    Anders Burla
    0

    If you use the starter kit try and change the payment country in the dropdown in step 2 of the cart. That should change the currency when you go to step 3

  • Tommy Pedersen 15 posts 65 karma points
    Aug 29, 2013 @ 11:20
    Tommy Pedersen
    0

    yep that changes the currency, ty s i just need to add that feature to pageload. =) ill just see if i can do that and if im getting it working ill mark your answer as the solution.

  • Tommy Pedersen 15 posts 65 karma points
    Aug 29, 2013 @ 11:56
    Tommy Pedersen
    0

    Okay so i made up a Razor file and made a macro thats uses it. i have to say this razor thing is pretty new to me. so from here in this razor file i make a page_load ? that change the country/currency ? and any hints on how?

  • Anders Burla 2560 posts 8256 karma points
    Aug 29, 2013 @ 13:52
    Anders Burla
    0

    Hi Tommy

    The best way to learn Razor for Umbraco is using their tv platform:
    http://umbraco.tv/

    To set the Country using the Razor API of Tea Commerce see this link:
    http://documentation.teacommerce.net/razor-api/country/setcurrentpaymentcountry/
    You will have to run some code on every page load (happesn if its placed in a macro that renders everytime) and here you will change the country depending on which url the customer is using.

    Kind regards
    Anders

  • Tommy Pedersen 15 posts 65 karma points
    Aug 29, 2013 @ 14:09
    Tommy Pedersen
    0

    Atm i made this method. it stil fails on c in the foreach

    @{
        //Store id
        long storeId = long.Parse( Model._Store );
    
        IEnumerable<Country> countries = TC.GetCountries(storeId);
        string cultureName = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
    
        foreach (Country c in countries)
        {
            if (cultureName == c.ToString())
            {
                //Found current culture and matching attribute culture...
                Country country = TC.GetCurrentPaymentCountry(storeId);
            }
    
            Response.Write(@"<script language='javascript'>alert('" + c.ToString() + "');</script>");
        }
    }
    

    so think im getting closer for the solution i hope =)

  • Tommy Pedersen 15 posts 65 karma points
    Aug 29, 2013 @ 15:29
    Tommy Pedersen
    100

    I made a solution that looks like this in a razor macro added to the masterpage

    @{
        //Store id
        long storeId = long.Parse( Model._Store );
    
        string cultureName = (String)System.Threading.Thread.CurrentThread.CurrentCulture.Name;
        Country country;
    
        foreach(Country co in TC.GetCountries(storeId))
        {
            if(co.RegionCode == cultureName)
            {
                country = TC.SetCurrentPaymentCountry(storeId, co.Id);
            }
        }
    }
    
  • Anders Burla 2560 posts 8256 karma points
    Sep 02, 2013 @ 10:20
    Anders Burla
    0

    You could refactor to

    Country country = TC.GetCountries(storeId).SingleOrDefault(c => c.RegionCode == cultureName);
    if(country != null){
      TC.SetCurrentPaymentCountry(storeId, country.Id);
    }

    Just a bit shorter :)

  • Tommy Pedersen 15 posts 65 karma points
    Sep 03, 2013 @ 02:01
    Tommy Pedersen
    0

    ty for that =)

Please Sign in or register to post replies

Write your reply to:

Draft