Product add to cart improvement

  • Posts: 1119
  • Thank you received: 114
5 years 10 months ago #302370

Hi,

We see sometimes that product/variant has been added twice to shopping cart. Seems it's because of user click add to cart button twice accidentally or maybe slow internet response...

Is there a way to add some kinda check and prevent button to be clicked again until first click adds product to cart?
I see that button gets "add_in_progress" class so there must be some trigger we could use and disable button until it's finished?

Please advise.

Thank you

Last edit: 5 years 10 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
5 years 10 months ago #302405

Hi,

That's an interesting idea.
Change the code:

if(className) o.addClass(el, className);
to:
if(className){
 if(o.hasClass(el, className)) {
  return;
 }
 o.addClass(el, className);
}
in the file media/com_hikashop/js/hikashop.js
Note however that the drawback I see is that if the first add to cart request fails for some reason (network issue for example), you'll render the add to cart button unsuable unless the user refreshes the page, so that might not be such a good idea.

Please Log in or Create an account to join the conversation.

Time to create page: 0.052 seconds
Powered by Kunena Forum