Somewhere after my store update to version 1.6.1 (not sure if this is related), I lost the ability to change the currency on the store.
What I already did:
Changed theme to default;
Disabled overrides;
Cleared caches and cookies;
Uninstalled/Installed Currency Block.
No results, so far. How far did I get:
On setCurrency() call, ajax call is returning 1... so I believe it's working that far.
The page is reloading, but the currency remains the same.
What I believe it's happening: Cookie is not being set!
In this function on ChangeCurrencyController.php, I believe something is not working (maybe the line before ajaxDie('1') where cookie is set):
public function initContent()
{
$currency = new Currency((int)Tools::getValue('id_currency'));
if (Validate::isLoadedObject($currency) && !$currency->deleted)
{
$this->context->cookie->id_currency = (int)$currency->id;
$this->ajaxDie('1');
}
$this->ajaxDie('0');
}
There's a friend's computer where the cookies weren't cleared since the last updates, where this is working. I believe he has a cookie that is updated on currency change. If I delete his cookies I guess it will stop working. Or is this nonsense?
Can someone give me a hand here?
Can it be something else that has nothing to do with the cookies?
Thanks,
I had the same problem, it is not a bug, when you change the currency prestashop change it back based on your browser language. There is an option to turn off in localization > localization > settings > define default country based on browser language > off
Related
I'm making a website right now and need to use django-tracking2 for analytics. Everything works but I would like to allow users to opt out and I haven't seen any options for that. I was thinking modifying the middleware portion may work but honestly, I don't know how to go about that yet since I haven't written middleware before.
I tried writing a script to check a cookie called no_track and if it wasn't set, I would set it to false for default tracking and if they reject, it sets no_track to True but I had no idea where to implement it (other than the middle ware, when I tried that the server told me to contact the administrator). I was thinking maybe I could use signals to prevent the user being tracked but then that would slow down the webpage since it would have to deal with preventing a new Visitor instance on each page (because it would likely keep making new instances since it would seem like a new user). Could I subclass the Visitor class and modify __init__ to do a check for the cookie and either let it save or don't.
Thanks for any answers, if I find a solution I'll edit the post or post and accept the answer just in case someone else needs this.
I made a function in my tools file (holds all functions used throughout the project to make my life easier) to get and set a session key. Inside the VisitorTrackingMiddleware I used the function _should_track() and placed a check that looks for the session key (after _should_track() checks that sessions is installed and before all other checks), with the check_session() function in my tools file, if it doesn't exist, the function creates it with the default of True (Track the user until they accept or reject) and returns an HttpResponse (left over from trying the cookie method).
When I used the cookie method, the firefox console said the cookie will expire so I just switched to sessions another reason is that django-tracking2 runs on it.
It seems to work very well and it didn't have a very large impact on load times, every time a request is made, that function runs and my debug tells me if it's tracking me or not and all the buttons work through AJAX. I want to run some tests to see if this does indeed work and if so, maybe I'll submit a pull request to django-tracking2 just in case someone else wants to use it.
A Big advantage to this is that you can allow users to change their minds if they want or you can reprompt at user sign up depending on if they accepted or not. with the way check_session() is set up, I can use it in template tags and class methods as well.
I got this blog link about distinguishing between first time and returning users. From what I understand I will set a super property ("First Time") for every user who comes on my website as "True"(treating all users brand new) if that super property isn't set else if it is set as "True" I will change it to "False". But the code given in the above blog doesn't seem to be doing that.
mixpanel.track("Home Page Viewed");
mixpanel.register({"First Time": "FALSE"});
Where is it checking if "First Time"property is already set or not? Or is there any fault in my understanding ?
Also super properties will expire once the cookie expires as they are stored there. So how to persist them ? Increase the cookie lifetime ?
When clicking on a link that links to my Sitecore site, I expect Tracker.Current.Interaction.Referrer to be filled. However, it is not.
I know there are scenario's where you don't get a Referrer: https://stackoverflow.com/a/6880668/1797792
Strange thing is however, that HttpContext.Current.Request.UrlReferrer.Host does contain the referrer in my case. So why isn't the Sitecore Tracker aware of this? And more importantly, how do I make it aware?
Turns out that Tracker.Current.Interaction doesn't reset if you come from a different referrer. It is saved in the session.
It only sets the Tracker.Current.Interaction.Referrer if Tracker.Current.Interaction == null
Closing the browser and then coming clicking on a link referring to the site will fill Tracker.Current.Interaction.Referrer like expected.
I have two sites both served by one Sitecore solution, and am having a problem where the following code is forcing language embedding in the URLs of one of the two sites because the double-asterisk-enclosed piece of code below from the base LinkProvider is returning true (the "lang" cookie key returns null).
private bool EmbedLanguage()
{
if (this._options.LanguageEmbedding == LanguageEmbedding.Always)
{
return true;
}
if (this._options.LanguageEmbedding == LanguageEmbedding.Never)
{
return false;
}
SiteContext site = Context.Site;
return ((site == null) || **((WebUtil.GetOriginalCookieValue(site.GetCookieKey("lang")) == null)** || this._options.EmbedLanguage(Context.Language)));
}
This only does this for one of the two sites, and not the other. The languageEmbedding value in the linkManager in Web.config is "asNeeded." The first (behaving) site is multi-language, and the other (not behaving) is not.
It's not clear why the behaving one is getting its "lang" cookie set, and the other is not. They're both sharing quite a bit of code, and the problematic site hasn't deviated much from the original one beyond anything other than a layout, new sublayouts, etc. The guts are pretty much the same.
Any ideas would be welcomed. Perhaps it's something really obvious I'm missing?
First of all let me clarify if i have understood your question correctly.
You have 2 Sites running on same Code. (Multi-Site)
One is Multi-Language, It behaves fine (Sets the Lang cookie)
Another is Single Language, It behaves odd and does not set the Lang cookie.
How you have implemented multi-site?
It looks like you are using the mentioned function to embed language in URL in some class.
So suggesting a workaround we have implemented.
Sometime IE8 Deletes the cookie and that's the reason we have moved our multisite solution from languageEmbedding= asNeeded to Never.
We have override the LinkManager Class and when we are generating the URLs for the site we check the setting placed on the Site Home Page if the site is multi-language then we set the languageEmbedding= always. else it is already never.
This way we never face issue with language cookies.
Yes, It will not set the cookie when it is a single language site and languageEmbedding is set to never.
The way we ended up resolving this is by adding a custom "embedLanguageInUrl" attribute to the problem site in web.config, and setting it to "never." We then used a SiteContextExtensions class to expose that value (Sitecore.Context.Site.EmbedLanguageInUrl()), and then adjust the urlOptions.LanguageEmbedding value appropriately, if needed. Seems to work great. :)
I've got an object, Question, that I've created an edit page for. This worked fine. Someone would edit the question and changes would show up on the page that just showed the question. Recently however, I started noticing the changes did NOT show up on the list of questions. This problem persists after having changed the cache-backend to the dummybackend. When running the developmentserver, I see the request with a nice 200 code. Print statements I put into the view, that I expected to show up in the output of de dev-server, do not show up. So apperently the view method isn't even called. I get the feeling the 200 code does not mean something wasn't retrieved from cache.
Three ways I noticed, make the website show the change in the object after it has been saved:
1. Signing the current user out of the website and then logging in again.
2. Appending ?something=whatever to the url.
3. Waiting for an unknown amount of time. I tried if the waitingtime could be changed by modifying session-parameters, but to no avail.
Though I think it is possible to use that last method, it doesn't feel right. And it means means quite a bit of work to solve a problem that wasn't there before. And I'd like to know just what happend.
Here is the cache-bit from settings.py. No surprises there I'd think:
CACHES = {
'default':{
'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}}
And, because logging out & in helps, the session stuff:
SESSION_ENGINE = 'django.contrib.sessions.backends.file'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_AGE = 60
Oh and this problem is also in the admin..
Suggestions?