0

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;
    }
}
  • Any update if my explenation works for you? – CompactCode Nov 4 '17 at 16:46
3
  • custom_price : new price that can be declared by user and recalculated during calculation process.

  • original_custom_price : original defined value of custom price without any convertion.

It will be safe to set both.

This link can be useful.

0

Both the SetCustomPrice and SetOriginalCustomPrice seems to be a part of the Quote Update system.

First lets understand the difference between ->setPrice() ->setOriginalPrice()

    • price - initial item price, declared during product association
    • original_price - product price before any calculations

Now the difference between setPrice and SetCustomPrice you already know i think. A price is the price of the product in your product stock. Custom Price is the price that you give it on your order.

So SetCustomPrice is the price you give it in your invoice and SetCustomOriginalPrice is the Product Price that you give it but before any calculations (before any discounts etc)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.