Magento 1

Modifying the Price of a Cart Item

Magento provides a relatively easy way to modify the price of a cart item:



– The checkout_cart_product_add_after passes an instance of the product being added and the quote order item to the observer.

The Observer Method

public function modifyItem($observer){
	$item = $observer->getQuoteItem();
	$item = $item->getParentItem() ? $item->getParentItem() : $item; 

– This will set the cart item to have a price of 2000.
– Remember to get the parent item of the cart item if we’re adding configurables to the cart.
– I’m not entirely sure what the setIsSuperMode does, it only appears in Magento’s core code once and doesn’t appear to be used anywhere else (unless I’m missing something), so it’s only here for completeness.