A group product is a collection of simple products that can be purchased individually only. By default when we add an item of group product to cart, it will display parent product before that as well on cart and checkout page e.g. Parent Product Name → Child Product Name.
In this tutorial we’ll learn how to remove parent product name when a child of group product is added to cart and checkout page.
First of all create a group product that will serve as a parent product. I’ve entered a self explanatory name for this i.e. Parent Product.
Now assign some child products to it by creating and assigning simple products.
After assigning some child products to parent go to parent product from front end and add one of child product to cart.
On proceeding to cart and checkout page you’ll see parent product title attached before child product title.
Product on cart will be like:
And on checkout page will be:
Now we need to remove parent product title.
To do this add the following lines of code at the end of your theme’s functions.php file:
function gfl_product_title($title, $product) { return $product->post->post_title;; } add_filter('woocommerce_product_title', 'gfl_product_title', 10, 2);
Place the code in functions.php and save the file.
After that again go to cart and checkout pages and parent product title will be removed.
And the checkout page will be:
Great article, helped me! 🙂