This topic has 4 replies, 2 voices, and was last updated 8 years, 2 months ago ago by Jack Richardson
is it possible to show the sku # alongside the product name in the items list?
We’d like to show:
Product Picture
Product Name
Sku #
Price
Hello,
Try the following code in functions.php:
add_action( 'woocommerce_after_shop_loop_item_title', 'shop_sku' );
function shop_sku(){
global $product;
echo '<span itemprop="productID" class="sku">SKU: ' . $product->sku . '</span>';
}
We recommend to add it in child theme functions.php file https://codex.wordpress.org/Child_Themes
Best regards,
Jack Richardson.
Thank you that worked. How can center it with the rest of the text?
Hello,
In this case edit the previous code to this:
add_action( 'woocommerce_after_shop_loop_item_title', 'shop_sku' );
function shop_sku(){
global $product;
echo '<div itemprop="productID" class="sku">SKU: ' . $product->sku . '</div>';
}
and add this code in style.css of your child theme or in custom.css file of the parent theme:
.sku {
text-align: center;
}
Best regards,
Jack Richardson.
Tagged: product list, show sku, templates, woocommerce, wordpress
You must be logged in to reply to this topic.Log in/Sign up