Jump to content

Edit History

MadMar

MadMar

Hello everybody :D
I encountered an awkward problem!
Scenario:

  1. I enter to homepage of my shop (https://www.grelaparfum.it/) in incognito mode. I have several products in home page: new products block, featured products block etc. I try to add to cart any product and it is added to cart (via ajax). Works like a charme.
  2. At this moment, I login into my site. Return in home page... and all "add to cart buttons" stop working. I don't have any console errors or any errors in general. Simply, I click on button and after 2/3 seconds, the button clicked (went in disabled state) comes back to normal. As i never clicked it. And nothing happen. 
  3. I go to an any category page, click on add to cart and it works.
  4. At this point, I clear the cache: the buttons in home page work again. 

 

So, after several code inspections, i noticed that while in category page the "add_to_cart_url" had a token, in homepage the buttons had a different token (i got output both $token and $static_token). 
If i use the token used by buttons in category page in home page add to cart button, it works. When i clear cache, tokens in homepage come update... and works.

 

Is the "add_to_cart_url" in cache maybe? And this happens with native and custom modules. How can prevent caching of add_to_cart_url?


[EDIT] Another awkward fact is that on the developer site (a subdomain), the problem is not happens. I copy from dev subdomain to main domain. Did I forget to do something? 












 

MadMar

MadMar

Hello everybody :D
I encountered an awkward problem!
Scenario:

  1. I enter to homepage of my shop (https://www.grelaparfum.it/) in incognito mode. I have several products in home page: new products block, featured products block etc. I try to add to cart any product and it is added to cart (via ajax). Works like a charme.
  2. At this moment, I login into my site. Return in home page... and all "add to cart buttons" stop working. I don't have any console errors or any errors in general. Simply, I click on button and after 2/3 seconds, the button clicked (went in disabled state) comes back to normal. As i never clicked it. And nothing happen. 
  3. I go to an any category page, click on add to cart and it works.
  4. At this point, I clear the cache: the buttons in home page work again. 

 

So, after several code inspections, i noticed that while in category page the "add_to_cart_url" had a token, in homepage the buttons had a different token (i got output both $token and $static_token). 
If i use the token used by buttons in category page in home page add to cart button, it works. When i clear cache, tokens in homepage come update... and works.

 

Is the "add_to_cart_url" in cache maybe? And this happens with native and custom modules. How can prevent caching of add_to_cart_url?


[EDIT] Another awkward fact is that on the developer site (a subdomain), the problem is not happens. I copy from dev subdomain to main domain. Maybe i forgot to do something?













 

MadMar

MadMar

Hello everybody :D
I encountered an awkward problem!
Scenario:

  1. I enter to homepage of my shop (https://www.grelaparfum.it/) in incognito mode. I have several products in home page: new products block, featured products block etc. I try to add to cart any product and it is added to cart (via ajax). Works like a charme.
  2. At this moment, I login into my site. Return in home page... and all "add to cart buttons" stop working. I don't have any console errors or any errors in general. Simply, I click on button and after 2/3 seconds, the button clicked (went in disabled state) comes back to normal. As i never clicked it. And nothing happen. 
  3. I go to an any category page, click on add to cart and it works.
  4. At this point, I clear the cache: the buttons in home page work again. 

 

So, after several code inspections, i noticed that while in category page the "add_to_cart_url" had a token, in homepage the buttons had a different token (i got output both $token and $static_token). 
If i use the token used by buttons in category page in home page add to cart button, it works. When i clear cache, tokens in homepage come update... and works.

 

Is the "add_to_cart_url" in cache maybe? And this happens with native and custom modules. How can prevent caching of add_to_cart_url?
















 

MadMar

MadMar

Hello everybody :D
I encountered an awkward problem!
Scenario:

  1. I enter to homepage of my shop (https://www.grelaparfum.it/) in incognito mode. I have several products in home page: new products block, featured products block etc. I try to add to cart any product and it is added to cart (via ajax). Works like a charme.
  2. At this moment, I login into my site. Return in home page... and all "add to cart buttons" stop working. I don't have any console errors or any errors in general. Simply, I click on button and after 2/3 seconds, the button clicked (went in disabled state) comes back to normal. As i never clicked it. And nothing happen. 
  3. I go to an any category page, click on add to cart and it works.
  4. At this point, I clear the cache: the buttons in home page work again. 

 

So, after several code inspections, i noticed that while in category page the "add_to_cart_url" had a token, in homepage the buttons had a different token (i got output both $token and $static_token). 
If i use the token used by buttons in category page in home page add to cart button, it works. When i clear cache, tokens in homepage come update... and works.

 

Is the "add_to_cart_url" in cache maybe? And this happens with native and custom modules. How can I disable caching of add_to_cart_url?
















 

×
×
  • Create New...