Greetings,
I’m trying to implement in shop product loop additional code, which displays below title product SKU. Somehow it doesn’t work. Changes are made in child theme.
Code
// Add SKU and custom text to product list
function display_sku_and_custom_text_in_product_list() {
global $product;
// Check if the product has a SKU
$sku = $product->get_sku();
// Display SKU
if ($sku) {
echo '<div class="product-sku">SKU: ' . esc_html($sku) . '</div>';
}
// Display custom text
echo '<div class="custom-text">Test</div>';
}
add_action('woocommerce_before_shop_loop_item_title', 'display_sku_and_custom_text_in_product_list', 10);