SuiteCommerce Advanced: Call to service before page load

290 Views Asked by At

I have requirment of IP redirection in SCA site, based on my custom record.

We have county<-->data mapping stored in custom record data is of language, currencies, season type.

We are fetching county code from maxmind, and passing this to our custom service which then gives us require data

var urlRoot= "services/Service.ss?siteid="+siteid+"&continent="+continent+"&country_code="+country_code+"&city="+city;

Everthing is working fine for us, but only sometimew later as we are using some delay, This is because SCA page renders everything first and then our service.

Is there are ways to call our custom service first and pass data in url

once our service is called we are generating this below url

www.oursite.com?lang=fr_FR&cur=GBP

we are doing all this in Shopping starter file.

Help will apprietate.

1

There are 1 best solutions below

5
On

You can try making the call within the Router file of your module. That way you can run view.showContent in the .done function of your request.

var  urlRoot= "services/IP.Service.ss?siteid="+siteid+"&continent="+continent+"&country_code="+country_code+"&city="+city;
urlRoot = _.getAbsoluteUrl(urlRoot);


$.get(urlRoot).done(function(data)
{
    // do something with data
    var options = {data: data};

    view.showContent(options);
});