Reload after change quantity function

Hi,

I would like to ask if someone can help me to find a solution for this problem…

how to avoid reload page after  change the quantity of the product in Cart??

Thanks,

Maha

Hi Maha,

why do you want to avoid the reload? The quantity of a product was changed and so the state of the shopping cart. So it has to be recalculated. For that we have to reload the page. 

Best regards from Schöppingen

cool Michael Telgmann

Hi Micheal,

I want to move all the function of the cart to the  Off-Canvas. should not mouve after changing the quantity :frowning:

Best Regards from Berlin.

Hey @maha,

I second [@Michael Telgmann](http://forum.shopware.com/profile/17553/Michael Telgmann „Michael Telgmann“)‍ answer. The calculation of the basket is the main issue you’re facing. If you really wanna use an AJAX request to change the quantity you can implement it on your own.

We’re doing a similar thing for the variant change on the product detail page. Take a look on the following source code: shopware/jquery.ajax-variant.js at 5.3 · shopware/shopware · GitHub

I’ll break down what you have to do to reach your goal:

  • Add an „submit“ event listener to the form which represents a row in the basket
  • Read out the action and method attribute from the form and serialize the form itself. You need these information to create your AJAX request
  • When you’re getting the data from the server, you have to find the information from the returned HTML document
  • Next you have to find the elements containing the old information and replace them with the new information from the server response
  • Up next you need to reinitialize the jQuery plugins which are used on the basket page

I hope this small list can help you out to understand what you have to do. Please keep in mind this is not a trivial task and takes quite a lot effort.

Best regards,
Stephan Pohl  Shopware

@Michael Telgmann schrieb:

why do you wanft to avoid the reload? 

 

Noticed that location.reload() is slower than the other methods.

location.reload(forceGet)

forceGet:

  • false - Default. Reloads the current page from the cache.
  • true - The current page must be reloaded from the server.

From the Mozilla Developement Network I guess the .reload method may fetch all files from the Server again. This would be similar to a CTRL + F5 reload.

The location.href for example, simply follows the link which may be cached. As for the MDN definition the behave is not clearly defined so I guess its browser and case specific behave.

 

 

Hello…

How can i run a function after cart updates?

Regards ThopTV