Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento custom price on Quote Item is ignored?

Tags:

magento

I want to be able to change price on Quote Items to be different than on Products, based on several Tutorials I have used this code:

$quoteItem->setCustomPrice($price);
$quoteItem->setOriginalCustomPrice($price);
$quoteItem->getProduct()->setIsSuperMode(true);
$quote->save();

After that when I get to cart it shows normal prices, not custom price. I have checked Quote Items in cart and they have correct customPrice, but it seems to be ignored. Do I have to activate something else to make this custom prices to take effect?

PS:

Magento v1.7

like image 299
Tomáš Chylý Avatar asked Dec 20 '22 22:12

Tomáš Chylý


1 Answers

OK, so I found the problem, somehow it didnt get saved in my script. Not sure why, but I have rewritten my code into 2 functions, 1 for adding product, the other for changing price.

So this code is all that is necessary:

$quoteItem->setCustomPrice($price);
$quoteItem->setOriginalCustomPrice($price);
$quoteItem->getProduct()->setIsSuperMode(true);
$quoteItem->save();

No need to save quote, just quoteItem.

like image 180
Tomáš Chylý Avatar answered Dec 22 '22 11:12

Tomáš Chylý