I would like to remove the price from the bundle product options in the entire site. The place I have noticed that get displayed are:
- Shopping Cart
- Review Your Cart Page
- Mini Cart
- Confirmation Emails
Things I have tried:
I created a new module and overrode \Magento\Bundle\Helper\Catalog\Product\Configuration
:
ZEndertech\BundleExtended\Helper\Catalog\Product\Configuration.php
<?php
namespace ZEndertech\BundleExtended\Helper\Catalog\Product;
use Magento\Catalog\Helper\Product\Configuration\ConfigurationInterface;
use Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
use Magento\Framework\App\Helper\AbstractHelper;
use \Magento\Bundle\Helper\Catalog\Product\Configuration as BaseConfiguration;
class Configuration extends BaseConfiguration
{
/**
* Get bundled selections (slections-products collection)
*
* Returns array of options objects.
* Each option object will contain array of selections objects
*
* @param ItemInterface $item
* @return array
*/
public function getBundleOptions(ItemInterface $item)
{
$options = [];
$product = $item->getProduct();
/** @var \Magento\Bundle\Model\Product\Type $typeInstance */
$typeInstance = $product->getTypeInstance();
// get bundle options
$optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
$bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : [];
if ($bundleOptionsIds) {
/** @var \Magento\Bundle\Model\ResourceModel\Option\Collection $optionsCollection */
$optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
// get and add bundle selections collection
$selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
$bundleSelectionIds = unserialize($selectionsQuoteItemOption->getValue());
if (!empty($bundleSelectionIds)) {
$selectionsCollection = $typeInstance->getSelectionsByIds($bundleSelectionIds, $product);
$bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
foreach ($bundleOptions as $bundleOption) {
if ($bundleOption->getSelections()) {
$option = ['label' => $bundleOption->getTitle(), 'value' => []];
$bundleSelections = $bundleOption->getSelections();
foreach ($bundleSelections as $bundleSelection) {
$qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
if ($qty) {
$option['value'][] = $qty . ' x '
. $this->escaper->escapeHtml($bundleSelection->getName());
}
}
if ($option['value']) {
$options[] = $option;
}
}
}
}
}
return $options;
}
}
I cleared the cache, but the price still appears next to the bundle options.
di.xml
files in your module?