I need to be able to update products that are already in the cart. I'm updating other values than the quantity (mainly custom options), so I can not use a simple "cart=update" request.
Using JSONP + a hashed form I currently accomplish the update task like this:
On the product page I:
* Verify if that item is in the cart (using FC.json.products)
* If that item is in the cart I store the unique FC.json product.id on that particular product form
* Some other UI stuff like feedback to the customer that shows you'll be updating the cart
The customer makes some changes or whatever and hits the 'update cart' button....
I have added a fcc.events.cart.preprocess.add_pre
* Checks if it can retrieve the unique product id stored on the element (which is the form)
* Verifies if that id actually matches a product in FC.json.products
* Does a JSONP request to the FC server to remove the product (cart=update&quantity=0&id=<id>)
* When the request is complete it calls
to continue to the normal add-to-cart process
* Returns 'pause' (while doing the request)
This works fine.. would this be a correct implementation of using preprocess.add_pre
for this to silently delete something if it meets certain criteria prior to adding a new product to the cart (combined it looks like you're updating something).
Or are there other shorter smarter ways?