<script>
$( document ).ready(function() {

let phrase1 = 'В наличии:';
let phrase2 = 'Нет в наличии';
let phrase3 = 'Очень много';


let productListNum = $('.js-product').length;

let tistore = setInterval(function() {
        let productLoaded = 0;    
        $('.js-product').each(function(){
            if($(this).attr("data-product-url")) productLoaded++;
        });

        if ( productLoaded==productListNum ){
            clearInterval(tistore) 
            showQuantInStore();
        };

}, 100);   


$('.js-store-grid-cont').on('tStoreRendered', function() {
    showQuantInStore();
});


function showQuantInStore(){
setTimeout(function(){
    $('.js-product').each(function(){
        
        let elem = $(this);
        let quant = elem.attr('data-product-inv');
        
        let text = `${phrase1} ${quant} шт.`;
        
        if(quant==0) text = phrase2;
        if(quant=='') text = phrase3;
        
        
        console.log(quant);
        
        elem.find('.t-store__card__imgwrapper').attr('data-product-inv-sec', text).addClass('t-text');
        elem.find('.t-slds__main').attr('data-product-inv-sec', text).addClass('t-text');

    });
}, 300); 
   
   
   
};


//При открытии карточки товара
$(document).on('click','a[href*="/tproduct/"]',function(e){ 
    showQuantInStore() 
});

$(document).on('change', '.js-product-controls-wrapper', function(){
    showQuantInStore() 
});


});
</script>


<style>
.js-product .t-slds__main {
    position: relative;
}

.js-product .t-slds__main:after {
    content: attr(data-product-inv-sec);
    color: #000;
    position: absolute;
    right: 20px;
    bottom: 20px;
    padding: 8px 16px;
    background-color: #fff;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    z-index:99;
}

.js-product .t-store__card__imgwrapper {
    position: relative;
}

.js-product .t-store__card__imgwrapper:after {
    content: attr(data-product-inv-sec);
    color: #000;
    position: absolute;
    right: 20px;
    bottom: 20px;
    padding: 8px 16px;
    background-color: #fff;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    z-index:99;
}

    
</style>
Made on
Tilda