Product name is not showing when you select the product variation after adding it to the cart showing variation name

 If you want to display the main product title instead of the variation title on the cart page and checkout page, you'll need to modify the code that retrieves the product title in the WooCommerce template files. Here's how you can do it:

1. Open the functions.php file of your active theme or child theme. 
2. Add the following code snippet:

 
PHP Code Here
add_filter( 'woocommerce_cart_item_name', 'display_main_product_title_in_cart', 10, 3 );
function display_main_product_title_in_cart( $product_name, $cart_item, $cart_item_key ) {
    $product = $cart_item['data'];
    if ( $product->is_type( 'variation' ) ) {
        $product_id = $product->get_parent_id();
        $main_product = wc_get_product( $product_id );
        if ( $main_product ) {
            return $main_product->get_name();
        }
    }
    return $product_name;
}

Cart page
Product name is not showing when you select the product variation after adding to cart showing variation name


Checkout page:

Product name is not showing when you select the product variation after adding to cart showing variation name




Save the changes to functions.php.
This code snippet hooks into the woocommerce_cart_item_name filter. When a product is a variation, it retrieves the parent product ID and then fetches the parent product object to get its main title.

Now, when a variation product is added to the cart, the main title of the product will be displayed instead of the variation title. Make sure to test this on your cart and checkout pages to ensure it works as expected.