I want to hide Bundle product option price if it is 0.00 on checkout page.

I have created a after plugin as following.


<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <type name="Magento\Bundle\Helper\Catalog\Product\Configuration">
        <plugin name="removeZeroPriceFromBundleItemOptions" type="Meta\Checkout\Plugin\Magento\Bundle\Helper\Catalog\Product\Configuration"/>

namespace Meta\Checkout\Plugin\Magento\Bundle\Helper\Catalog\Product;

class Configuration
     * remove zero price of bundle product item options 
     * from cart, minicart and order summary on checkout page
     * @param \Magento\Bundle\Helper\Catalog\Product\Configuration $options
     * @param $result
    public function afterGetBundleOptions(\Magento\Bundle\Helper\Catalog\Product\Configuration $options, array $result)
        $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/trackorder.log');
        $logger = new \Zend\Log\Logger();

        $count= 0;
        foreach($result as $option)
            if ( is_array($option['value']) ){  // if is array
                if($option['value'][0] != strip_tags($option['value'][0]) ) // if contains html tag
                    preg_match('/<span class="price">(.*?)<\/span>/s', $option['value'][0], $match);
                    $extractPrice = trim(strip_tags($match[0]));
                    $logger->info(filter_var($extractPrice, FILTER_SANITIZE_NUMBER_INT));
                    if(filter_var($extractPrice, FILTER_SANITIZE_NUMBER_INT) == 0)
                        $optionText = substr($option['value'][0] ,0,strpos($option['value'][0],'<span'));
                        $result[$count]['value'][0] = trim($optionText);


        return $result;


But it works only on cart page and in minicart, but does not work on checkout page order summary.

enter image description here

Additional findings:

What I noticed is, this plugin seems to work only on page load duration, it means when checkout page keeps loading then product option prices don't come but after page load below ajax is fired and then it reload order summary section and then option prices begin to display.


but since I already have applied plugin so this time prices should not come up with options.and I checked logs in plugin files are being printed when above ajax run.

So I am not sure why it is happening and why plugin output not being shown at frontend.

Any help/suggestion would be appreciated.

1 Answer 1


It worked.

actually I need to defined plugin in di.xml file in etc folder, not in etc/frontend/di.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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