简体   繁体   中英

How to speed up Ajax “add to cart” updates in Virtuemart shop?

I´m working on a Joomla powered webshop with Viruemart v.2.6.6

Everything is working well and the design is almost complete, but I see one little problem regarding the Ajax based "add to cart" function.

Whenever someone clicks "add to cart" a modal popup instantly pops up showing information: "Product successfully added to cart... Continue shopping? Go to cart?" but I can see in the mini-cart that it actually takes up to 3-4 seconds before the Ajax call has been processed and the product is updated into the cart.

The problem is that sometimes the lag between clicking the add-to-cart button and the actual cart update takes so long that if the customer then clicks the "Go to cart" link the cart will be empty..

My question is, does anyone have experience with optimization of this kind of Ajax calls and in particular with Virtuemart? As far as I can tell, in Virtuemart the add to cart form is controlled by the "js-recalculate" class which triggers the Ajax call.

Well, in this case "optimization" is a question of order. As I can understand from your description, when someone clicks Add to Cart button a simple confirmation window pops. Only when user confirms add to cart operation, it fires AJAX call.

I'd suggest you to use the following scheme:

  1. When use clicks Add to Cart button, do the ducking call right away!
  2. Don't forget to show "loading..." image or text and always do so.
  3. Only when response is received (product added to cart), show that Continue/Stay alert.

This is a standard behavior and it is pretty optimized and friendly to customers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM