Woocommmerce show SKU in cart page

How to show the SKU next to the product name in the cart page of Woocommerce ?

tried to copy it from the Meta.php of single product but it breaks the page…

Related posts

2 comments

  1. Add the following code to your theme’s functions.php file, or as a new plugin:

    add_filter( 'woocommerce_in_cart_product_title', '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(" (SKU: %s)", $sku) : $title;
    }
    
  2. For those finding this from google, here code that works on current versions (2.1+) of WooCommerce.

    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(" (SKU: %s)", $sku) : $title;
    }
    

    The code example from G.M. did not work for me, and my rep is too low to comment on his post.

    Source

Comments are closed.