cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2: setCustomPrice vs. setOriginalCustomPrice

Magento 2: setCustomPrice vs. setOriginalCustomPrice


Hello together,

I have seen several examples showing how to adjust prices in carts. I do not understand the difference between setCustomPrice and setOriginalCustomPrice. Where is CustomPrice and OriginalCustomPrice used later on?


    class CustomPrice implements ObserverInterface
    {
        public function execute(\Magento\Framework\Event\Observer $observer) {
    
    
            $item=$observer->getEvent()->getData('quote_item');
            $product=$observer->getEvent()->getData('product');
            $price = $item->getProduct()->getFinalPrice()+60;
            $item->setCustomPrice($price);
            $item->setOriginalCustomPrice($price);
            $item->getProduct()->setIsSuperMode(true);
            return $this;
        }
    }



1 REPLY 1

Re: Magento 2: setCustomPrice vs. setOriginalCustomPrice

This is a useful comment:

 

https://github.com/magento/magento2/blob/c077da60335dfeb72d9678d519e38d4191170dd9/app/code/Magento/Q...

 

It's probably safest to set both.

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!