Magento 1.7 – How to Update Product Custom Options on Cart Page

cartcustom-optionsmagento-1.7

I have a simple product with custom options. When someone select any option and click on add to cart the product with the option goes to the cart where the product and selected option is shown.

Now here comes the situation where I need to alter the flow of Magento. I want to update that option value on cart page. Being more specific I want to make customer able to select or change option on cart page.

What i have done so far is that I have traced that items are shown from template/checkoput/cart/item/default.phtml.

I have placed my custom option dropdown there in a row of product and placed a save button near the dropdown. But again how do I get it updated?

Best Answer

Interesting question. I suggest doing it not by adding "Update" button to each items but using generic Magento "Update Cart" routine.

In this case we can assume that values of your drop-downs will be submitted with the form. Then you can observe checkout_cart_update_items_after event, get updated options with Mage::app()->getFrontController()->getRequest()->getParam(...) and change the selected option of each item.

This is just my theoretical assumptions but I'm sure you were not expecting complete code. Otherwise there's a commercial extension out there which is doing exactly what you need.