Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created February 13, 2026 15:26
Show Gist options
  • Select an option

  • Save xlplugins/3e5991826b29227cb0dacd4574e8f529 to your computer and use it in GitHub Desktop.

Select an option

Save xlplugins/3e5991826b29227cb0dacd4574e8f529 to your computer and use it in GitHub Desktop.
blocksy theme compatibility with slide cart
add_action( 'wp_footer', function () {
?>
<script>
(function($) {
function updateSwatchLabel(form) {
$(form).find('.ct-variation-swatches').each(function() {
var sel = this.querySelector('select');
if (!sel) return;
var attr = (sel.dataset.attribute_name || '').replace('attribute_', '');
var val = sel.value;
var label = form.querySelector('[for="' + attr + '"]');
if (!label) return;
var span = label.querySelector('span');
var text = '';
$(sel).find('option').each(function() {
if (this.value === val) { text = $(this).text().trim(); return false; }
});
if (span) span.textContent = text ? ': ' + text : '';
else if (text) { span = document.createElement('span'); span.textContent = ': ' + text; label.appendChild(span); }
});
}
$(document.body).on('fkcart_cart_quick_view_open', function() {
setTimeout(function() {
var $drawer = $('.fkcart-drawer-content');
var $forms = $drawer.find('.variations_form');
if (!$forms.length) return;
$drawer.addClass('single-product product');
if (typeof $.fn.wc_variation_form === 'function') {
$forms.each(function() { $(this).wc_variation_form(); });
}
$forms.off('found_variation.blocksy-fkcart reset_data.blocksy-fkcart').on('found_variation.blocksy-fkcart reset_data.blocksy-fkcart', function() {
updateSwatchLabel(this);
});
$forms.each(function() { updateSwatchLabel(this); });
if (typeof ctEvents !== 'undefined') {
ctEvents.trigger('ct:custom-select:init');
ctEvents.trigger('ct:custom-select-allow:init');
ctEvents.trigger('blocksy:frontend:init');
}
$(document).trigger('yit_quick_view_loaded');
if (typeof window.wcpaInit === 'function') {
setTimeout(window.wcpaInit, 50);
}
}, 300);
});
})(jQuery);
</script>
<?php
}, 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment