0

I want to pass an extra class to swatch class which is formed via swatch renderer js based on the stock. The reason is the swatches are not being hidden if they are out of stock. This is what I am trying to do -

$.each($widget.options.jsonConfig.product_information, function () {
                    var item = this;
                    inStock = item.is_in_stock;              
                    if(inStock != true){
                        stockClass = 'hideStock';
                    } else{
                        stockClass = 'showStock';
                    }                 
                });


                attr =+
                    ' id="' + controlId + '-item-' + id + '"' +
                    ' aria-checked="false"' +
                    ' aria-describedby="' + controlId + '"' +
                    ' tabindex="0"' +
                    ' option-type="' + type + '"' +
                    ' option-id="' + id + '"' +
                    ' option-label="' + label + '"' +
                    ' aria-label="' + label + '"' +
                    ' option-tooltip-thumb="' + thumb + '"' +
                    ' option-tooltip-value="' + value + '"' +
                    ' title="' + stockClass + '"' +
                    ' class="' + stockClass + '"' +
                    ' role="option"';

The title is coming in the div, but not class. But the title is not coming correctly too. Its somehow looping twice. or Giving incorrect result.

0

Solved my problem using - https://github.com/magento/magento2/commit/4c99f2895cee70e48bff093e083a408972d82a7d

Patch provided

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.