1

I have set my product custom price in an observer..

$item->setOriginalCustomPrice(9.99);
$item->setCustomPrice(9.99);

I can output the price value correclty like so:

echo $item->getOriginalPrice();
// 9.99

But when I try to output it formatted, it gives me the original price.

$finalPrice = $product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue();
// £19.99

I tried

$finalPrice = $product->getPriceInfo()->getPrice('custom_price')->getAmount()->getValue();

But that gives an error.

1

Use this code for price with currency to display.

   $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

   $priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data'); 

   $finalPrice = $priceHelper->currency($product->getCustomPrice(), true, false);

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.