Adding SKU to any product title, variable, grouped or simple
-
Hello,
I have been trying a few days and I just cannot get it to work. No programmer here so I used snippets from all over the internet, including in this forum, resulting in no success.
I was hoping someone could help me with code that can be added easily to functions.php, to show the SKU under any product title (variable (list), grouped (list), simple). I might ask too much, but if possible, I would like to have a separated class for CSS styling for the SKU.
For the cart, I use this:
add_filter( 'woocommerce_cart_item_name', 'add_sku_in_cart', 20, 3); function add_sku_in_cart( $title, $values, $cart_item_key ) { $sku = $values['data']->get_sku(); return $sku ? $title . sprintf("<br>SKU: %s", $sku) : $title; }
-and that works well. I use SKUs for all products so the code above works for that.
Your help is greatly appreciated.Using the latest WooCommerce and WordPress.
Thank you in advance,
-Ronald
The page I need help with: [log in to see the link]
- The topic ‘Adding SKU to any product title, variable, grouped or simple’ is closed to new replies.