скрипт, который скрывает все ряды кнопок, начиная со второго, и добавляет кнопку "Показать ещё" для их отображения
актуально для категории. но в карточке тоже отлично работает
$(document).ready(function () {
$showMoreButton = $("<button class='show-more-hpmr'>Показати ще</button>");
$('.hpm-button-wrapper').each(function(){
const $buttons = $(this).children();
let rows = 1;
let prevOffsetTop = $buttons.first().offset().top;
$buttons.each(function () {
if ($(this).offset().top > prevOffsetTop) {
rows++;
prevOffsetTop = $(this).offset().top;
}
});
if(rows > 2)
{
const firstRowHeight = $buttons.first().outerHeight(true);
$(this).css('max-height', firstRowHeight + 'px');
$(this).css('overflow', 'hidden');
$showMoreButton.insertAfter($(this));
}
});
$(document).on('click', ".show-more-hpmr", function() {
$(this).prev().css('max-height', '111111px');
$(this).remove();
});
});