From 681a2a8ba5259aad771ee9e427d0ecf7a8572f96 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 11 Dec 2012 17:28:47 +0000 Subject: [PATCH] Groups product titles. Closes #1966. --- classes/class-wc-product-simple.php | 16 ++++++++++++++++ templates/single-product/add-to-cart/grouped.php | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/classes/class-wc-product-simple.php b/classes/class-wc-product-simple.php index 2a852d20e08..6ba4fa53ad5 100644 --- a/classes/class-wc-product-simple.php +++ b/classes/class-wc-product-simple.php @@ -56,6 +56,22 @@ class WC_Product_Simple extends WC_Product { $this->check_sale_price(); } + /** + * Get the title of the post. + * + * @access public + * @return string + */ + function get_title() { + + $title = $this->post->post_title; + + if ( $this->get_parent() > 0 ) { + $title = get_the_title( $this->get_parent() ) . ' → ' . $title; + } + + return apply_filters( 'woocommerce_product_title', apply_filters( 'the_title', $title, $this->id ), $this ); + } /** * Checks sale data to see if the product is due to go on sale/sale has expired, and updates the main price. diff --git a/templates/single-product/add-to-cart/grouped.php b/templates/single-product/add-to-cart/grouped.php index 550ba9c807e..7991602032c 100644 --- a/templates/single-product/add-to-cart/grouped.php +++ b/templates/single-product/add-to-cart/grouped.php @@ -54,9 +54,9 @@ foreach ( $product->get_children() as $child_id ) {