The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Feedback req. if this is a correct approach for updating a product (not just qty)

RolfRolf Member
in Help edited November 2012
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 method that:
    * 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
fcc.events.cart.preprocess.resume() 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?
Comments
  • fc_adamfc_adam FoxyCart Team
    @Rolf,

    That sounds like the best approach - could you share (or whisper) a URL for us to see it in action?
  • @fc_adam, this is currently a dev project and not live. As soon as possible I'll share a screen capture/movie clip or a test url.

    thx
Sign In or Register to comment.