How to show "YOU SAVE $XXX.XX" amount considering custom options (type RADIO/CHECKBOX) also on the product detail page when changing different option based on customer selection?
I have a simple product with two custom options.
- CHECKBOX and RADIO type, both having 'Fixed' as Price Type without option level SKU.
For price and sale price, I have a code as follows.
This seems to be working fine.
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $helper = $this->helper('Magento\Catalog\Helper\Data'); $youSave = 0.00; $proOrgPrice = $helper->getTaxPrice($_product,$_product->getPrice(),true); $finalPrice = $helper->getTaxPrice($_product,$_product->getFinalPrice(),true); $youSave = $proOrgPrice - $finalPrice; $price = $objectManager->create('Magento\Framework\Pricing\Helper\Data'); if( $youSave > 0): echo 'YOU ARE SAVING:'; echo $price->currency($youSave, true, false); endif; ?>
Require to show price depends on changing of custom options at frontend.