Magento 2.2.3 - Remove price from select field on product pageWhere should this JS go? re: Remove price from select field on product pagein product detail page custom option (product-options) price just display excluding price in + Magento 2How to hide price options on Configurable Product?Magento 2.1 Create a filter in the product grid by new attributeMagento 2: Remove price change from custom option dropdown in magento 2.2.3Header.links magento 2.2.3Install Amazon pay extension from admin panel in magento 2.2.3Move Newsletter Bar - Magento 2.2.3Magento 2 VAT - same product priceWhere should this JS go? re: Remove price from select field on product pageMagento 2.2.3 CE unable to add/remove item from wishlist?Magento2 select field valueBootstrap3 Multi-Select-Field - select an ID twice
What are the exact meanings of roll, pitch and yaw?
expansion with *.txt in the shell doesn't work if no .txt file exists
What was the rationale behind 36 bit computer architectures?
Why is a dedicated QA team member necessary?
Why is my read in of data taking so long?
What is the lowest-speed bogey a jet fighter can intercept/escort?
Where to place an artificial gland in the human body?
kids pooling money for Lego League and taxes
How do I stop my characters falling in love?
Is there anything wrong with Thrawn?
A planet illuminated by a black hole?
How do I run a game when my PCs have different approaches to combat?
Strange Cron Job takes up 100% of CPU Ubuntu 18 LTS Server
How to write a sincerely religious protagonist without preaching or affirming or judging their worldview?
Why was Sauron not trying to find the Ring, and instead of preparing for war?
Why can't my huge trees be chopped down?
powerhouse of ideas
How do I address my Catering staff subordinate seen eating from a chafing dish before the customers?
What should I say when a company asks you why someone (a friend) who was fired left?
Memory capability and powers of 2
What does Kasparov mean by "I was behind in three and even in one after six games"?
Character is called by their first initial. How do I write it?
What does "see" in "the Holy See" mean?
Does the Intel 8086 CPU have user mode and kernel mode?
Magento 2.2.3 - Remove price from select field on product page
Where should this JS go? re: Remove price from select field on product pagein product detail page custom option (product-options) price just display excluding price in + Magento 2How to hide price options on Configurable Product?Magento 2.1 Create a filter in the product grid by new attributeMagento 2: Remove price change from custom option dropdown in magento 2.2.3Header.links magento 2.2.3Install Amazon pay extension from admin panel in magento 2.2.3Move Newsletter Bar - Magento 2.2.3Magento 2 VAT - same product priceWhere should this JS go? re: Remove price from select field on product pageMagento 2.2.3 CE unable to add/remove item from wishlist?Magento2 select field valueBootstrap3 Multi-Select-Field - select an ID twice
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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: appcodeMagentoCatalogBlockProductViewOptionsTypeSelect.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.
Does anyone know where I can change this?
magento2 product magento2.2.3 select option
add a comment |
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: appcodeMagentoCatalogBlockProductViewOptionsTypeSelect.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.
Does anyone know where I can change this?
magento2 product magento2.2.3 select option
You need to override that Class using di.xml.
– Sukumar Gorai
Jul 27 '18 at 14:39
add a comment |
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: appcodeMagentoCatalogBlockProductViewOptionsTypeSelect.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.
Does anyone know where I can change this?
magento2 product magento2.2.3 select option
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: appcodeMagentoCatalogBlockProductViewOptionsTypeSelect.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.
Does anyone know where I can change this?
magento2 product magento2.2.3 select option
magento2 product magento2.2.3 select option
asked Jul 27 '18 at 13:49
Remco HendriksRemco Hendriks
5610 bronze badges
5610 bronze badges
You need to override that Class using di.xml.
– Sukumar Gorai
Jul 27 '18 at 14:39
add a comment |
You need to override that Class using di.xml.
– Sukumar Gorai
Jul 27 '18 at 14:39
You need to override that Class using di.xml.
– Sukumar Gorai
Jul 27 '18 at 14:39
You need to override that Class using di.xml.
– Sukumar Gorai
Jul 27 '18 at 14:39
add a comment |
4 Answers
4
active
oldest
votes
I created a JS solution which removes the price from the option. This function fires when the select changes which occurs when the price is added to the option field. It then checks each option for "+€" and "-€" this could be any currency however. It then removes everything from this sign so it returns the option without the price behind it.
$('select.product-custom-option').change(function()
$('option').each(function()
var selectedOption = $(this).text();
if (selectedOption.indexOf('+€') > -1)
selectedOption = selectedOption.substring(0, selectedOption.indexOf('+€'));
$(this).text(selectedOption);
else if (selectedOption.indexOf('-€') > -1)
selectedOption = selectedOption.substring(0, selectedOption.indexOf('-€'));
$(this).text(selectedOption);
);
);
The result:
Follow-up question by a new user here: magento.stackexchange.com/questions/239650/…
– tripleee
Aug 27 '18 at 4:23
Thanks tried this one and worked well from my end. Using Magento 2.2.6
– MazeStricks
Oct 8 '18 at 15:07
add a comment |
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/
add a comment |
You need to create your own module and can manage to work by following code:
Add the below code to your di.xml. Location of di.xml will:
app/code/Vendor/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCatalogBlockProductViewOptionsTypeSelect" type="VendorModuleBlockProductViewOptionsTypeSelect" />
</config>
Create one file Select.php at below location:
app/code/Vendor/Module/Block/Product/View/Options/Type/Select.php
Content of Select.php:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorModuleBlockProductViewOptionsType;
/**
* Product options text type block
*
* @api
* @since 100.0.2
*/
class Select extends MagentoCatalogBlockProductViewOptionsTypeSelect
/**
* Return html for control element
*
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function getValuesHtml()
$_option->getType() == MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_CHECKBOX
)
$selectHtml = '<div class="options-list nested" id="options-' . $_option->getId() . '-list">';
$require = $_option->getIsRequire() ? ' required' : '';
$arraySign = '';
switch ($_option->getType())
case MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_RADIO:
$type = 'radio';
$class = 'radio admin__control-radio';
if (!$_option->getIsRequire())
$selectHtml .= '<div class="field choice admin__field admin__field-option">' .
'<input type="radio" id="options_' .
$_option->getId() .
'" class="' .
$class .
' product-custom-option" name="options[' .
$_option->getId() .
']"' .
' data-selector="options[' . $_option->getId() . ']"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' value="" checked="checked" /><label class="label admin__field-label" for="options_' .
$_option->getId() .
'"><span>' .
__('None') . '</span></label></div>';
break;
case MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_CHECKBOX:
$type = 'checkbox';
$class = 'checkbox admin__control-checkbox';
$arraySign = '[]';
break;
$count = 1;
foreach ($_option->getValues() as $_value)
$count++;
$priceStr = $this->_formatPrice(
[
'is_percent' => $_value->getPriceType() == 'percent',
'pricing_value' => $_value->getPrice($_value->getPriceType() == 'percent'),
]
);
$htmlValue = $_value->getOptionTypeId();
if ($arraySign)
$checked = is_array($configValue) && in_array($htmlValue, $configValue) ? 'checked' : '';
else
$checked = $configValue == $htmlValue ? 'checked' : '';
$dataSelector = 'options[' . $_option->getId() . ']';
if ($arraySign)
$dataSelector .= '[' . $htmlValue . ']';
$selectHtml .= '<div class="field choice admin__field admin__field-option' .
$require .
'">' .
'<input type="' .
$type .
'" class="' .
$class .
' ' .
$require .
' product-custom-option"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' name="options[' .
$_option->getId() .
']' .
$arraySign .
'" id="options_' .
$_option->getId() .
'_' .
$count .
'" value="' .
$htmlValue .
'" ' .
$checked .
' data-selector="' . $dataSelector . '"' .
' price="' .
$this->pricingHelper->currencyByStore($_value->getPrice(true), $store, false) .
'" />' .
'<label class="label admin__field-label" for="options_' .
$_option->getId() .
'_' .
$count .
'"><span>' .
$_value->getTitle() .
'</span> ' .
//$priceStr .
'</label>';
$selectHtml .= '</div>';
$selectHtml .= '</div>';
return $selectHtml;
Hmm I created my own module following your code and that part works when I change the code I can make the select field dissappear. However I can still see the price after the option while i commented the $priceStr.
– Remco Hendriks
Jul 30 '18 at 9:27
Could it be that the price is generated somewhere else?
– Remco Hendriks
Jul 30 '18 at 9:27
This is working fine for me for custom options select.
– Sukumar Gorai
Jul 30 '18 at 9:35
Okay something else is happening right know, the "option + €0,00" is gone at first but is added a few seconds later. Is there another piece of code somewhere that interferes with this code?
– Remco Hendriks
Jul 30 '18 at 10:17
I think you are using some extension or js which includes it.
– Sukumar Gorai
Jul 31 '18 at 14:15
|
show 1 more comment
I found another way to hide the "+price" from dropdown
I've just edited
pub/static/frontend/(vendor)/(theme)/(Language)/Magento_Catalog/js/price-options.js
var globalOptions =
productId: null,
priceHolderSelector: '.price-box', //data-role="priceBox"
optionsSelector: '.product-custom-option',
optionConfig: ,
optionHandlers: ,
optionTemplate: '<%= data.label %>'
/*edited +
'<% if (data.finalPrice.value) %>' +
' +<%- data.finalPrice.formatted %>' +
'<% %>'
edited*/,
controlContainer: 'dd'
;
Then "php bin/magento cache:clean && php bin/magento cache:flush"
Many thanks to the analysts who pointed out other answers.
1
This might temporarily solve it but when you refresh the static content you have to change it again.
– Remco Hendriks
Oct 12 '18 at 7:07
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f236276%2fmagento-2-2-3-remove-price-from-select-field-on-product-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
I created a JS solution which removes the price from the option. This function fires when the select changes which occurs when the price is added to the option field. It then checks each option for "+€" and "-€" this could be any currency however. It then removes everything from this sign so it returns the option without the price behind it.
$('select.product-custom-option').change(function()
$('option').each(function()
var selectedOption = $(this).text();
if (selectedOption.indexOf('+€') > -1)
selectedOption = selectedOption.substring(0, selectedOption.indexOf('+€'));
$(this).text(selectedOption);
else if (selectedOption.indexOf('-€') > -1)
selectedOption = selectedOption.substring(0, selectedOption.indexOf('-€'));
$(this).text(selectedOption);
);
);
The result:
Follow-up question by a new user here: magento.stackexchange.com/questions/239650/…
– tripleee
Aug 27 '18 at 4:23
Thanks tried this one and worked well from my end. Using Magento 2.2.6
– MazeStricks
Oct 8 '18 at 15:07
add a comment |
I created a JS solution which removes the price from the option. This function fires when the select changes which occurs when the price is added to the option field. It then checks each option for "+€" and "-€" this could be any currency however. It then removes everything from this sign so it returns the option without the price behind it.
$('select.product-custom-option').change(function()
$('option').each(function()
var selectedOption = $(this).text();
if (selectedOption.indexOf('+€') > -1)
selectedOption = selectedOption.substring(0, selectedOption.indexOf('+€'));
$(this).text(selectedOption);
else if (selectedOption.indexOf('-€') > -1)
selectedOption = selectedOption.substring(0, selectedOption.indexOf('-€'));
$(this).text(selectedOption);
);
);
The result:
Follow-up question by a new user here: magento.stackexchange.com/questions/239650/…
– tripleee
Aug 27 '18 at 4:23
Thanks tried this one and worked well from my end. Using Magento 2.2.6
– MazeStricks
Oct 8 '18 at 15:07
add a comment |
I created a JS solution which removes the price from the option. This function fires when the select changes which occurs when the price is added to the option field. It then checks each option for "+€" and "-€" this could be any currency however. It then removes everything from this sign so it returns the option without the price behind it.
$('select.product-custom-option').change(function()
$('option').each(function()
var selectedOption = $(this).text();
if (selectedOption.indexOf('+€') > -1)
selectedOption = selectedOption.substring(0, selectedOption.indexOf('+€'));
$(this).text(selectedOption);
else if (selectedOption.indexOf('-€') > -1)
selectedOption = selectedOption.substring(0, selectedOption.indexOf('-€'));
$(this).text(selectedOption);
);
);
The result:
I created a JS solution which removes the price from the option. This function fires when the select changes which occurs when the price is added to the option field. It then checks each option for "+€" and "-€" this could be any currency however. It then removes everything from this sign so it returns the option without the price behind it.
$('select.product-custom-option').change(function()
$('option').each(function()
var selectedOption = $(this).text();
if (selectedOption.indexOf('+€') > -1)
selectedOption = selectedOption.substring(0, selectedOption.indexOf('+€'));
$(this).text(selectedOption);
else if (selectedOption.indexOf('-€') > -1)
selectedOption = selectedOption.substring(0, selectedOption.indexOf('-€'));
$(this).text(selectedOption);
);
);
The result:
edited Jul 30 '18 at 12:40
answered Jul 30 '18 at 11:44
Remco HendriksRemco Hendriks
5610 bronze badges
5610 bronze badges
Follow-up question by a new user here: magento.stackexchange.com/questions/239650/…
– tripleee
Aug 27 '18 at 4:23
Thanks tried this one and worked well from my end. Using Magento 2.2.6
– MazeStricks
Oct 8 '18 at 15:07
add a comment |
Follow-up question by a new user here: magento.stackexchange.com/questions/239650/…
– tripleee
Aug 27 '18 at 4:23
Thanks tried this one and worked well from my end. Using Magento 2.2.6
– MazeStricks
Oct 8 '18 at 15:07
Follow-up question by a new user here: magento.stackexchange.com/questions/239650/…
– tripleee
Aug 27 '18 at 4:23
Follow-up question by a new user here: magento.stackexchange.com/questions/239650/…
– tripleee
Aug 27 '18 at 4:23
Thanks tried this one and worked well from my end. Using Magento 2.2.6
– MazeStricks
Oct 8 '18 at 15:07
Thanks tried this one and worked well from my end. Using Magento 2.2.6
– MazeStricks
Oct 8 '18 at 15:07
add a comment |
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/
add a comment |
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/
add a comment |
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/
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/
answered Jul 16 at 20:47
Cadence LabsCadence Labs
111 bronze badge
111 bronze badge
add a comment |
add a comment |
You need to create your own module and can manage to work by following code:
Add the below code to your di.xml. Location of di.xml will:
app/code/Vendor/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCatalogBlockProductViewOptionsTypeSelect" type="VendorModuleBlockProductViewOptionsTypeSelect" />
</config>
Create one file Select.php at below location:
app/code/Vendor/Module/Block/Product/View/Options/Type/Select.php
Content of Select.php:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorModuleBlockProductViewOptionsType;
/**
* Product options text type block
*
* @api
* @since 100.0.2
*/
class Select extends MagentoCatalogBlockProductViewOptionsTypeSelect
/**
* Return html for control element
*
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function getValuesHtml()
$_option->getType() == MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_CHECKBOX
)
$selectHtml = '<div class="options-list nested" id="options-' . $_option->getId() . '-list">';
$require = $_option->getIsRequire() ? ' required' : '';
$arraySign = '';
switch ($_option->getType())
case MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_RADIO:
$type = 'radio';
$class = 'radio admin__control-radio';
if (!$_option->getIsRequire())
$selectHtml .= '<div class="field choice admin__field admin__field-option">' .
'<input type="radio" id="options_' .
$_option->getId() .
'" class="' .
$class .
' product-custom-option" name="options[' .
$_option->getId() .
']"' .
' data-selector="options[' . $_option->getId() . ']"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' value="" checked="checked" /><label class="label admin__field-label" for="options_' .
$_option->getId() .
'"><span>' .
__('None') . '</span></label></div>';
break;
case MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_CHECKBOX:
$type = 'checkbox';
$class = 'checkbox admin__control-checkbox';
$arraySign = '[]';
break;
$count = 1;
foreach ($_option->getValues() as $_value)
$count++;
$priceStr = $this->_formatPrice(
[
'is_percent' => $_value->getPriceType() == 'percent',
'pricing_value' => $_value->getPrice($_value->getPriceType() == 'percent'),
]
);
$htmlValue = $_value->getOptionTypeId();
if ($arraySign)
$checked = is_array($configValue) && in_array($htmlValue, $configValue) ? 'checked' : '';
else
$checked = $configValue == $htmlValue ? 'checked' : '';
$dataSelector = 'options[' . $_option->getId() . ']';
if ($arraySign)
$dataSelector .= '[' . $htmlValue . ']';
$selectHtml .= '<div class="field choice admin__field admin__field-option' .
$require .
'">' .
'<input type="' .
$type .
'" class="' .
$class .
' ' .
$require .
' product-custom-option"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' name="options[' .
$_option->getId() .
']' .
$arraySign .
'" id="options_' .
$_option->getId() .
'_' .
$count .
'" value="' .
$htmlValue .
'" ' .
$checked .
' data-selector="' . $dataSelector . '"' .
' price="' .
$this->pricingHelper->currencyByStore($_value->getPrice(true), $store, false) .
'" />' .
'<label class="label admin__field-label" for="options_' .
$_option->getId() .
'_' .
$count .
'"><span>' .
$_value->getTitle() .
'</span> ' .
//$priceStr .
'</label>';
$selectHtml .= '</div>';
$selectHtml .= '</div>';
return $selectHtml;
Hmm I created my own module following your code and that part works when I change the code I can make the select field dissappear. However I can still see the price after the option while i commented the $priceStr.
– Remco Hendriks
Jul 30 '18 at 9:27
Could it be that the price is generated somewhere else?
– Remco Hendriks
Jul 30 '18 at 9:27
This is working fine for me for custom options select.
– Sukumar Gorai
Jul 30 '18 at 9:35
Okay something else is happening right know, the "option + €0,00" is gone at first but is added a few seconds later. Is there another piece of code somewhere that interferes with this code?
– Remco Hendriks
Jul 30 '18 at 10:17
I think you are using some extension or js which includes it.
– Sukumar Gorai
Jul 31 '18 at 14:15
|
show 1 more comment
You need to create your own module and can manage to work by following code:
Add the below code to your di.xml. Location of di.xml will:
app/code/Vendor/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCatalogBlockProductViewOptionsTypeSelect" type="VendorModuleBlockProductViewOptionsTypeSelect" />
</config>
Create one file Select.php at below location:
app/code/Vendor/Module/Block/Product/View/Options/Type/Select.php
Content of Select.php:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorModuleBlockProductViewOptionsType;
/**
* Product options text type block
*
* @api
* @since 100.0.2
*/
class Select extends MagentoCatalogBlockProductViewOptionsTypeSelect
/**
* Return html for control element
*
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function getValuesHtml()
$_option->getType() == MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_CHECKBOX
)
$selectHtml = '<div class="options-list nested" id="options-' . $_option->getId() . '-list">';
$require = $_option->getIsRequire() ? ' required' : '';
$arraySign = '';
switch ($_option->getType())
case MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_RADIO:
$type = 'radio';
$class = 'radio admin__control-radio';
if (!$_option->getIsRequire())
$selectHtml .= '<div class="field choice admin__field admin__field-option">' .
'<input type="radio" id="options_' .
$_option->getId() .
'" class="' .
$class .
' product-custom-option" name="options[' .
$_option->getId() .
']"' .
' data-selector="options[' . $_option->getId() . ']"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' value="" checked="checked" /><label class="label admin__field-label" for="options_' .
$_option->getId() .
'"><span>' .
__('None') . '</span></label></div>';
break;
case MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_CHECKBOX:
$type = 'checkbox';
$class = 'checkbox admin__control-checkbox';
$arraySign = '[]';
break;
$count = 1;
foreach ($_option->getValues() as $_value)
$count++;
$priceStr = $this->_formatPrice(
[
'is_percent' => $_value->getPriceType() == 'percent',
'pricing_value' => $_value->getPrice($_value->getPriceType() == 'percent'),
]
);
$htmlValue = $_value->getOptionTypeId();
if ($arraySign)
$checked = is_array($configValue) && in_array($htmlValue, $configValue) ? 'checked' : '';
else
$checked = $configValue == $htmlValue ? 'checked' : '';
$dataSelector = 'options[' . $_option->getId() . ']';
if ($arraySign)
$dataSelector .= '[' . $htmlValue . ']';
$selectHtml .= '<div class="field choice admin__field admin__field-option' .
$require .
'">' .
'<input type="' .
$type .
'" class="' .
$class .
' ' .
$require .
' product-custom-option"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' name="options[' .
$_option->getId() .
']' .
$arraySign .
'" id="options_' .
$_option->getId() .
'_' .
$count .
'" value="' .
$htmlValue .
'" ' .
$checked .
' data-selector="' . $dataSelector . '"' .
' price="' .
$this->pricingHelper->currencyByStore($_value->getPrice(true), $store, false) .
'" />' .
'<label class="label admin__field-label" for="options_' .
$_option->getId() .
'_' .
$count .
'"><span>' .
$_value->getTitle() .
'</span> ' .
//$priceStr .
'</label>';
$selectHtml .= '</div>';
$selectHtml .= '</div>';
return $selectHtml;
Hmm I created my own module following your code and that part works when I change the code I can make the select field dissappear. However I can still see the price after the option while i commented the $priceStr.
– Remco Hendriks
Jul 30 '18 at 9:27
Could it be that the price is generated somewhere else?
– Remco Hendriks
Jul 30 '18 at 9:27
This is working fine for me for custom options select.
– Sukumar Gorai
Jul 30 '18 at 9:35
Okay something else is happening right know, the "option + €0,00" is gone at first but is added a few seconds later. Is there another piece of code somewhere that interferes with this code?
– Remco Hendriks
Jul 30 '18 at 10:17
I think you are using some extension or js which includes it.
– Sukumar Gorai
Jul 31 '18 at 14:15
|
show 1 more comment
You need to create your own module and can manage to work by following code:
Add the below code to your di.xml. Location of di.xml will:
app/code/Vendor/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCatalogBlockProductViewOptionsTypeSelect" type="VendorModuleBlockProductViewOptionsTypeSelect" />
</config>
Create one file Select.php at below location:
app/code/Vendor/Module/Block/Product/View/Options/Type/Select.php
Content of Select.php:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorModuleBlockProductViewOptionsType;
/**
* Product options text type block
*
* @api
* @since 100.0.2
*/
class Select extends MagentoCatalogBlockProductViewOptionsTypeSelect
/**
* Return html for control element
*
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function getValuesHtml()
$_option->getType() == MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_CHECKBOX
)
$selectHtml = '<div class="options-list nested" id="options-' . $_option->getId() . '-list">';
$require = $_option->getIsRequire() ? ' required' : '';
$arraySign = '';
switch ($_option->getType())
case MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_RADIO:
$type = 'radio';
$class = 'radio admin__control-radio';
if (!$_option->getIsRequire())
$selectHtml .= '<div class="field choice admin__field admin__field-option">' .
'<input type="radio" id="options_' .
$_option->getId() .
'" class="' .
$class .
' product-custom-option" name="options[' .
$_option->getId() .
']"' .
' data-selector="options[' . $_option->getId() . ']"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' value="" checked="checked" /><label class="label admin__field-label" for="options_' .
$_option->getId() .
'"><span>' .
__('None') . '</span></label></div>';
break;
case MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_CHECKBOX:
$type = 'checkbox';
$class = 'checkbox admin__control-checkbox';
$arraySign = '[]';
break;
$count = 1;
foreach ($_option->getValues() as $_value)
$count++;
$priceStr = $this->_formatPrice(
[
'is_percent' => $_value->getPriceType() == 'percent',
'pricing_value' => $_value->getPrice($_value->getPriceType() == 'percent'),
]
);
$htmlValue = $_value->getOptionTypeId();
if ($arraySign)
$checked = is_array($configValue) && in_array($htmlValue, $configValue) ? 'checked' : '';
else
$checked = $configValue == $htmlValue ? 'checked' : '';
$dataSelector = 'options[' . $_option->getId() . ']';
if ($arraySign)
$dataSelector .= '[' . $htmlValue . ']';
$selectHtml .= '<div class="field choice admin__field admin__field-option' .
$require .
'">' .
'<input type="' .
$type .
'" class="' .
$class .
' ' .
$require .
' product-custom-option"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' name="options[' .
$_option->getId() .
']' .
$arraySign .
'" id="options_' .
$_option->getId() .
'_' .
$count .
'" value="' .
$htmlValue .
'" ' .
$checked .
' data-selector="' . $dataSelector . '"' .
' price="' .
$this->pricingHelper->currencyByStore($_value->getPrice(true), $store, false) .
'" />' .
'<label class="label admin__field-label" for="options_' .
$_option->getId() .
'_' .
$count .
'"><span>' .
$_value->getTitle() .
'</span> ' .
//$priceStr .
'</label>';
$selectHtml .= '</div>';
$selectHtml .= '</div>';
return $selectHtml;
You need to create your own module and can manage to work by following code:
Add the below code to your di.xml. Location of di.xml will:
app/code/Vendor/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoCatalogBlockProductViewOptionsTypeSelect" type="VendorModuleBlockProductViewOptionsTypeSelect" />
</config>
Create one file Select.php at below location:
app/code/Vendor/Module/Block/Product/View/Options/Type/Select.php
Content of Select.php:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace VendorModuleBlockProductViewOptionsType;
/**
* Product options text type block
*
* @api
* @since 100.0.2
*/
class Select extends MagentoCatalogBlockProductViewOptionsTypeSelect
/**
* Return html for control element
*
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function getValuesHtml()
$_option->getType() == MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_CHECKBOX
)
$selectHtml = '<div class="options-list nested" id="options-' . $_option->getId() . '-list">';
$require = $_option->getIsRequire() ? ' required' : '';
$arraySign = '';
switch ($_option->getType())
case MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_RADIO:
$type = 'radio';
$class = 'radio admin__control-radio';
if (!$_option->getIsRequire())
$selectHtml .= '<div class="field choice admin__field admin__field-option">' .
'<input type="radio" id="options_' .
$_option->getId() .
'" class="' .
$class .
' product-custom-option" name="options[' .
$_option->getId() .
']"' .
' data-selector="options[' . $_option->getId() . ']"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' value="" checked="checked" /><label class="label admin__field-label" for="options_' .
$_option->getId() .
'"><span>' .
__('None') . '</span></label></div>';
break;
case MagentoCatalogApiDataProductCustomOptionInterface::OPTION_TYPE_CHECKBOX:
$type = 'checkbox';
$class = 'checkbox admin__control-checkbox';
$arraySign = '[]';
break;
$count = 1;
foreach ($_option->getValues() as $_value)
$count++;
$priceStr = $this->_formatPrice(
[
'is_percent' => $_value->getPriceType() == 'percent',
'pricing_value' => $_value->getPrice($_value->getPriceType() == 'percent'),
]
);
$htmlValue = $_value->getOptionTypeId();
if ($arraySign)
$checked = is_array($configValue) && in_array($htmlValue, $configValue) ? 'checked' : '';
else
$checked = $configValue == $htmlValue ? 'checked' : '';
$dataSelector = 'options[' . $_option->getId() . ']';
if ($arraySign)
$dataSelector .= '[' . $htmlValue . ']';
$selectHtml .= '<div class="field choice admin__field admin__field-option' .
$require .
'">' .
'<input type="' .
$type .
'" class="' .
$class .
' ' .
$require .
' product-custom-option"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' name="options[' .
$_option->getId() .
']' .
$arraySign .
'" id="options_' .
$_option->getId() .
'_' .
$count .
'" value="' .
$htmlValue .
'" ' .
$checked .
' data-selector="' . $dataSelector . '"' .
' price="' .
$this->pricingHelper->currencyByStore($_value->getPrice(true), $store, false) .
'" />' .
'<label class="label admin__field-label" for="options_' .
$_option->getId() .
'_' .
$count .
'"><span>' .
$_value->getTitle() .
'</span> ' .
//$priceStr .
'</label>';
$selectHtml .= '</div>';
$selectHtml .= '</div>';
return $selectHtml;
answered Jul 27 '18 at 14:56
Sukumar GoraiSukumar Gorai
7,6743 gold badges8 silver badges32 bronze badges
7,6743 gold badges8 silver badges32 bronze badges
Hmm I created my own module following your code and that part works when I change the code I can make the select field dissappear. However I can still see the price after the option while i commented the $priceStr.
– Remco Hendriks
Jul 30 '18 at 9:27
Could it be that the price is generated somewhere else?
– Remco Hendriks
Jul 30 '18 at 9:27
This is working fine for me for custom options select.
– Sukumar Gorai
Jul 30 '18 at 9:35
Okay something else is happening right know, the "option + €0,00" is gone at first but is added a few seconds later. Is there another piece of code somewhere that interferes with this code?
– Remco Hendriks
Jul 30 '18 at 10:17
I think you are using some extension or js which includes it.
– Sukumar Gorai
Jul 31 '18 at 14:15
|
show 1 more comment
Hmm I created my own module following your code and that part works when I change the code I can make the select field dissappear. However I can still see the price after the option while i commented the $priceStr.
– Remco Hendriks
Jul 30 '18 at 9:27
Could it be that the price is generated somewhere else?
– Remco Hendriks
Jul 30 '18 at 9:27
This is working fine for me for custom options select.
– Sukumar Gorai
Jul 30 '18 at 9:35
Okay something else is happening right know, the "option + €0,00" is gone at first but is added a few seconds later. Is there another piece of code somewhere that interferes with this code?
– Remco Hendriks
Jul 30 '18 at 10:17
I think you are using some extension or js which includes it.
– Sukumar Gorai
Jul 31 '18 at 14:15
Hmm I created my own module following your code and that part works when I change the code I can make the select field dissappear. However I can still see the price after the option while i commented the $priceStr.
– Remco Hendriks
Jul 30 '18 at 9:27
Hmm I created my own module following your code and that part works when I change the code I can make the select field dissappear. However I can still see the price after the option while i commented the $priceStr.
– Remco Hendriks
Jul 30 '18 at 9:27
Could it be that the price is generated somewhere else?
– Remco Hendriks
Jul 30 '18 at 9:27
Could it be that the price is generated somewhere else?
– Remco Hendriks
Jul 30 '18 at 9:27
This is working fine for me for custom options select.
– Sukumar Gorai
Jul 30 '18 at 9:35
This is working fine for me for custom options select.
– Sukumar Gorai
Jul 30 '18 at 9:35
Okay something else is happening right know, the "option + €0,00" is gone at first but is added a few seconds later. Is there another piece of code somewhere that interferes with this code?
– Remco Hendriks
Jul 30 '18 at 10:17
Okay something else is happening right know, the "option + €0,00" is gone at first but is added a few seconds later. Is there another piece of code somewhere that interferes with this code?
– Remco Hendriks
Jul 30 '18 at 10:17
I think you are using some extension or js which includes it.
– Sukumar Gorai
Jul 31 '18 at 14:15
I think you are using some extension or js which includes it.
– Sukumar Gorai
Jul 31 '18 at 14:15
|
show 1 more comment
I found another way to hide the "+price" from dropdown
I've just edited
pub/static/frontend/(vendor)/(theme)/(Language)/Magento_Catalog/js/price-options.js
var globalOptions =
productId: null,
priceHolderSelector: '.price-box', //data-role="priceBox"
optionsSelector: '.product-custom-option',
optionConfig: ,
optionHandlers: ,
optionTemplate: '<%= data.label %>'
/*edited +
'<% if (data.finalPrice.value) %>' +
' +<%- data.finalPrice.formatted %>' +
'<% %>'
edited*/,
controlContainer: 'dd'
;
Then "php bin/magento cache:clean && php bin/magento cache:flush"
Many thanks to the analysts who pointed out other answers.
1
This might temporarily solve it but when you refresh the static content you have to change it again.
– Remco Hendriks
Oct 12 '18 at 7:07
add a comment |
I found another way to hide the "+price" from dropdown
I've just edited
pub/static/frontend/(vendor)/(theme)/(Language)/Magento_Catalog/js/price-options.js
var globalOptions =
productId: null,
priceHolderSelector: '.price-box', //data-role="priceBox"
optionsSelector: '.product-custom-option',
optionConfig: ,
optionHandlers: ,
optionTemplate: '<%= data.label %>'
/*edited +
'<% if (data.finalPrice.value) %>' +
' +<%- data.finalPrice.formatted %>' +
'<% %>'
edited*/,
controlContainer: 'dd'
;
Then "php bin/magento cache:clean && php bin/magento cache:flush"
Many thanks to the analysts who pointed out other answers.
1
This might temporarily solve it but when you refresh the static content you have to change it again.
– Remco Hendriks
Oct 12 '18 at 7:07
add a comment |
I found another way to hide the "+price" from dropdown
I've just edited
pub/static/frontend/(vendor)/(theme)/(Language)/Magento_Catalog/js/price-options.js
var globalOptions =
productId: null,
priceHolderSelector: '.price-box', //data-role="priceBox"
optionsSelector: '.product-custom-option',
optionConfig: ,
optionHandlers: ,
optionTemplate: '<%= data.label %>'
/*edited +
'<% if (data.finalPrice.value) %>' +
' +<%- data.finalPrice.formatted %>' +
'<% %>'
edited*/,
controlContainer: 'dd'
;
Then "php bin/magento cache:clean && php bin/magento cache:flush"
Many thanks to the analysts who pointed out other answers.
I found another way to hide the "+price" from dropdown
I've just edited
pub/static/frontend/(vendor)/(theme)/(Language)/Magento_Catalog/js/price-options.js
var globalOptions =
productId: null,
priceHolderSelector: '.price-box', //data-role="priceBox"
optionsSelector: '.product-custom-option',
optionConfig: ,
optionHandlers: ,
optionTemplate: '<%= data.label %>'
/*edited +
'<% if (data.finalPrice.value) %>' +
' +<%- data.finalPrice.formatted %>' +
'<% %>'
edited*/,
controlContainer: 'dd'
;
Then "php bin/magento cache:clean && php bin/magento cache:flush"
Many thanks to the analysts who pointed out other answers.
answered Oct 11 '18 at 20:04
Felipe AlvesFelipe Alves
62 bronze badges
62 bronze badges
1
This might temporarily solve it but when you refresh the static content you have to change it again.
– Remco Hendriks
Oct 12 '18 at 7:07
add a comment |
1
This might temporarily solve it but when you refresh the static content you have to change it again.
– Remco Hendriks
Oct 12 '18 at 7:07
1
1
This might temporarily solve it but when you refresh the static content you have to change it again.
– Remco Hendriks
Oct 12 '18 at 7:07
This might temporarily solve it but when you refresh the static content you have to change it again.
– Remco Hendriks
Oct 12 '18 at 7:07
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f236276%2fmagento-2-2-3-remove-price-from-select-field-on-product-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You need to override that Class using di.xml.
– Sukumar Gorai
Jul 27 '18 at 14:39