0

Hello and thank you for any assistance with this. I have tried many things to make this work but nothing has worked so far.

I have tried every solution on this page:

Magento 2.2.3 - Remove price from select field on product page

https://community.magento.com/t5/Magento-2-x-Programming/Show-actual-price-for-each-option-in-dropdown-for-configurable/td-p/406916

The only one that works is adding script to the select.phtml. The problem with this is I have custom options types so I can pick when I want the price hidden vs not hidden. Cleverly Named DROP_DOWN_PRICE_HIDDEN...

I have select.php edited, multiple.php edited, I have deleted the price diff section from configurable.js.

No matter what I try it keeps coming back. None of the mixins worked for me or directly editing the core js files (just for test). Something new appears to be running on top of all these other places.

Also after any js edit I ran the following commands:

rm -rf var/*
rm -rf pub/static/frontend/* -R
bin/magento setup:static-content:deploy -f
history | grep di
bin/magento setup:di:compile
bin/magento s:up
bin/magento c:f

Can anyone help?

-------------------------------ADD ON-------------------- While waiting I decided I would try to work with the JQUERY code which removes the price for ALL SELECT options. I tried to match the jquery by id since they are unique. Wouldn't work, it deleted all the prices from each type of select. I decided to add a new class "name" into my custom option type. The jquery still overrides all select drop_downs. I have no idea why, this seemed like a quick fix now this doesn't seem to be able to do the job either!

Here is the jquery code:

<script>
require(['jquery','domReady!'], function ($) {
$(document).ready(function(){
    $('select.price_hidden_select').change(function(){
        $('option').each(function(){
            var selectedOption = $(this).text();
                        if (selectedOption.indexOf('+') > -1) {
                            selectedOption = selectedOption.substring(0, selectedOption.indexOf('+'));
                $(this).text(selectedOption);
                        }
        });
    });
});
});
</script>

1 Answer 1

0

Okay so here is what I have which I consider a quick fix since I couldn't trace all the places this is getting added.

on the select.phtml I amended:

<script>
require(['jquery','domReady!'], function ($) {
   $(document).ready(function(){
      $('select.product-custom-option').change(function(){
         $('option').each(function(){
            var selectedOption = $(this).text();
            var selectedClass = $(this).parent().hasClass('price_hidden_select');
            if (selectedOption.indexOf('+') > -1 && selectedClass) {
               selectedOption = selectedOption.substring(0, selectedOption.indexOf('+'));
               $(this).text(selectedOption);
            }
         });
      });
   });
});
</script>

I also have modifications to my multiple.php where I am adding to the end of class descriptor 'price_hidden_select' for my custom option type.

Now I don't feel this is perfect but it gets the job done. I am open to more robust suggestions! Thanks!

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.