Magento 2.2.3 – Remove Price from Select Field on Product Page

magento2magento2.2.3optionproductselect

I was trying to remove the price which Magento adds to the options in a Select field but can't seem to get rid of the price. From what I could find on the internet it should be edited on the following location: app\code\Magento\Catalog\Block\Product\View\Options\Type\Select.php

At rule 62

$_value->getTitle() . ' ' . strip_tags($priceStr) . '',

And the following bit at rule 170 – 173

$_value->getTitle() .
'</span> ' .
$priceStr .
'</label>';

I changed these but the price still shows up in the select field as can be seen on the Image below.
enter image description here

Does anyone know where I can change this?

Best Answer

This is an update for Magento 2.2 and 2.3 --- the proper way to remove this is to override a JavaScript file into the active theme, and remove a section of code

The culprit is

vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js - line 415

// vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js
// ... Line 415 on Magento 2.2.x, 2.3.x

if (optionPriceDiff !== 0) {
    options[i].label = options[i].label + ' ' + priceUtils.formatPrice(
        optionPriceDiff,
        this.options.priceFormat,
        true);
}
// ...

Commenting out the above code block will remove the price increase without the need to add an additional binding onto the page.

Full article here: https://www.cadence-labs.com/2019/07/magento-2-remove-price-from-select-dropdown-on/

EDIT - 8th June 2020: The lines to comment out for Magento 2.3.5 are lines 460 - 466.

Related Topic