I got the sku to to show in the cart for each item - Does anyone have the correct php code to get the sku under each product name on all pages?
2 Answers
You can use the woocommerce_single_product_summary
hook,
so code will be like
add_action( 'woocommerce_single_product_summary', 'product_sku' ); function product_sku(){ global $product; echo '<div class="sku-product">' . $product->sku . '</div>'; }
This is the answer:
add_action( 'woocommerce_after_shop_loop_item_title', 'custom_after_title' ); function custom_after_title() {
global $product;
if ( $product->get_sku() ) { echo $product->get_sku(); }
}