0

I try to hide the price (in the screenshot +4,20€) on my Magento 2.3 but it doesn't work. I want only T2 display and not T2+4,20€.

I read and test a lot of posts too like but not working on my Magento 2.3.

Magento 2: how to hide ''price' of custom option in configurable product

Magento 2.2.3 - Remove price from select field on product page

Can someone help me to do this ?

Thanks.

enter image description here

0

You can able to extend below class where you can update configurable product options as required

\Magento\ConfigurableProduct\Model\ConfigurableAttributeData

function getAttributeOptionsData()

  • How to do that ? – Robert Jul 3 at 14:27
  • you will need to prepare module and override the above class in which you can customise the function and you can change option lable as per your requirement – Kinjal Patel Jul 3 at 14:34
  • Can you be more explicit ? I'm beginner and don't understand how to do that :( – Robert Jul 4 at 13:32
0

Try below code

Override following file:

app\design\frontend\theme_namespace\yourtheme\Magento_Catalog\templates\product\view\options\type\select.phtml

Now try with below code:

<script>
  require([
          'jquery',
          'domReady!'
      ], function ($) {
          $(document).ready(function () {
          $('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);
                      }
                  });     
              });     
          });
       });
</script>

php bin/magento c:c

  • I try the solution but it doesn't work. You add the script in the select.phtml ? – Robert Jul 3 at 14:27
  • Yes, add this in select.phtml, i have tried in my local its working – Ravi Soni Jul 3 at 14:50
  • It's not working on my local :( – Robert Jul 4 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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