Does anyone know how to display the SKU for each Single product title, underneath the Group product? I want to display the SKU to be obvious,as a second line,right below each product of the group.
3 Answers
Try with the CODE below:
global $woocommerce , $product;
$sku = $product->get_sku();
echo $sku;
-
1Hi Karan, welcome to WPSE. I've edited your answer with proper formatting. Please check this post to learn more about Markdown syntax used in StackExchange sites. Also, it's better for everyone if you also add some explanation with the CODE. Like where to put this CODE, which part of the problem does it solve and how etc. Hope to see you more in WPSE.– FayazCommented Apr 17, 2019 at 7:34
I want to show the sku coe below from any title in grouped child products.
Where to put that code? In functions.php?
Try the code below in functions.php:
function wc_show_sku_grouped_product($value, $grouped_product_child){
global $product;
$sku = $product->get_sku();
if(!empty($sku)){
$value .= "<div><strong>".__( 'SKU:', 'woocommerce' )." ".$sku."</strong></div>";
}
return $value;
}
add_filter('woocommerce_grouped_product_list_column_label', 'wc_show_sku_grouped_product', 10, 2);