Question

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.

Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top