Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created February 23, 2026 13:22
Show Gist options
  • Select an option

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

Select an option

Save xlplugins/d0b8d94d576f80d65e4632b33fd8033b to your computer and use it in GitHub Desktop.
cart upsell product short description
/**
* Upsell short description: show below product name (no layout changes)
*/
add_action( 'fkcart_before_upsell_price', function( $product_id, $cart_item ) {
if ( isset( $cart_item['product'] ) && $cart_item['product'] instanceof WC_Product ) {
$short_desc = $cart_item['product']->get_short_description();
if ( ! empty( $short_desc ) ) {
echo '<div class="fkcart-upsell-short-description">' . wp_kses_post( $short_desc ) . '</div>';
}
}
}, 10, 2 );
add_action( 'wp_footer', function() {
?>
<style id="fkcart-upsell-short-desc">
/* Only style the short description - no layout changes */
#fkcart-modal .fkcart-upsell-short-description {
font-size: 12px;
line-height: 1.4;
color: var(--fkcart-secondary-text-color, #82838E);
margin: 4px 0 0;
-webkit-line-clamp: 3;
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
}
</style>
<script>
(function() {
function moveUpsellShortDesc() {
document.querySelectorAll('.fkcart-upsell-short-description').forEach(function(el) {
if (el.dataset.moved) return;
var item = el.closest('.fkcart--item');
var title = item && item.querySelector('.fkcart-item-title');
var meta = item && item.querySelector('.fkcart-item-meta');
if (title && meta) {
meta.insertBefore(el, title.nextSibling);
el.dataset.moved = '1';
}
});
}
document.addEventListener('DOMContentLoaded', moveUpsellShortDesc);
var modal = document.getElementById('fkcart-modal');
if (modal) {
new MutationObserver(moveUpsellShortDesc).observe(modal, { childList: true, subtree: true });
}
})();
</script>
<?php
}, 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment