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);