Reputation: 407
Basically , I have a module which needs to Modify the price of the cart without touching any products, Say I have 2 test items:
The total price would be 66.99, I need to change this to 40.99 (40.99) would be variable, as would the (66.99) is there any way of doing this while complying with Magento's API
Upvotes: 1
Views: 230
Reputation: 2631
You can make use of one of Magentos events that are triggered when a product is added to the cart. For example the sales_quote_add_item
event.
You can then create an Observer where you update the price of the item added to the cart. This will not in any way alter the price of the actual product but only for that specific quote item.
Example of the observer method to update the price
public function updatePrice(Varien_Event_Observer $observer){
$item = $observer->getQuoteItem();
$price = $item->getProduct()->getFinalPrice();
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->setPrice($price);
$item->getProduct()->setIsSuperMode(true);
}
Upvotes: 1