Support » Plugin: WooCommerce » Adding SKU to any product title, variable, grouped or simple

  • Resolved Ronald van Arkel

    (@ronald-van-arkel)


    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]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Ronald van Arkel

    (@ronald-van-arkel)

    Hello,

    Would have thought this wasn’t so hard to do for the real die-hard programmer. I’ve looked again over the internet but still no luck, but the search continues and not going to give up on this ;).

    Thank you,

    -Ronald

    Zandy Ring

    (@zandyring)

    Automattic Happiness Engineer

    Hi Ronald,

    I like your spirit! Since there hasn’t been any activity on this thread, you may want to approach your local WordPress meetup group, and see if someone local would be willing to help you with this. You also might want to reach out to a Woo Expert ( http://www.woocommerce.com/experts/ ) to see if a professional developer would be willing to help (you can request a quote before committing to work).

    Cheers, and best of luck!

    Thread Starter Ronald van Arkel

    (@ronald-van-arkel)

    Hello Zandy,

    Thank you for your suggestions. It seems there is no easy way to “attach” the SKU after any title. This leaves me to hack/edit the files from woocommerce and place them in my child theme, as I have been doing already for grouped products. The good thing is that I do not use variable products so I can skip that part.

    I will look into the two options you gave me when I start to pull my hair out (normally after 3 days of digging and being lost in the code).

    Thank you Zandy,

    -Ronald

    Zandy Ring

    (@zandyring)

    Automattic Happiness Engineer

    Hi Ronald,

    Save your hair!

    I’ll leave the topic open for now, but if no one else chimes in over the next week or so, I’ll close it out.

    Take care!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding SKU to any product title, variable, grouped or simple’ is closed to new replies.