Function out of stock badge
Hello,
I'd like to add this function to add an “out of stock” badge on the thumbnails of this category page: https://madameaditoui.fr/categorie-produit/last-chance/
But what would be the term to use instead of : woocommerce_before_shop_loop_item_title
Thanks
----------------
add_action ('woocommerce_before_shop_loop_item_title', 'shm_woocommerce_before_shop_loop_item_title', 10);
//Add an out of stock overlay to product images when all variations are unavailable
function shm_woocommerce_before_shop_loop_item_title() {
global $product;
if ( !$product->is_in_stock() ) {
echo '<span class="sold-out-overlay">Vendu</span>';
}
};
-
Hi Romain,
Thank you for reaching out.
Providing support for custom code is beyond the scope of our support, so we recommend consulting with a developer for a more tailored solution.
However, you might consider using 'woocommerce_after_shop_loop_item' instead. This hook places the badge after the product wrapper, which can provide better control over its positioning and ensure it displays correctly within your category layout.
Best regards,
Ariel H.0
Please sign in to leave a comment.
Comments
1 comment