Add product ID as a sufix in product title for Woocommerce

Solution:1

Try this:

// For shop
function change_woocommerce_single_title($title, $id) {

    if ( in_array( get_post_type( $id ), array( 'product', 'product_variation') ) || is_product() )
      $title = $title . ' - ' . $id;
      
    return $title;
}

add_filter('the_title', 'change_woocommerce_single_title', 1, 2);

// For cart
function filter_woocommerce_cart_item_name( $item_name, $cart_item, $cart_item_key ) { 
    
    if( $cart_item['variation_id'] )
        $id = absint( $cart_item['variation_id'] );
    else
        $id = absint( $cart_item['product_id'] );
        
    $item_name = $item_name . ' - ' . $id;

    return $item_name;
    
}; 
         
add_filter('woocommerce_cart_item_name', 'filter_woocommerce_cart_item_name', 10, 3);

Solution:2

You can create your own function to handle the product title. Put this code to function.php of your child theme:

add_filter('the_title', 'change_woocommerce_single_title', 1, 2);

function change_woocommerce_single_title($title, $id) {

   if ( class_exists( 'woocommerce' ) && is_product())
      $title = $title . ' - ' . $id;
      
    return $title;
}