Keep backwards compatibility for variation title

This commit is contained in:
Claudio Sanches 2016-11-21 20:05:37 -02:00
parent 89e628f3d5
commit dd78bbd6ad
1 changed files with 11 additions and 1 deletions

View File

@ -459,7 +459,17 @@ abstract class WC_Abstract_Legacy_Product extends WC_Data {
* @return string
*/
public function get_title() {
return apply_filters( 'woocommerce_product_title', $this->get_post_data() ? $this->get_post_data()->post_title : '', $this );
_deprecated_function( 'WC_Product::get_title', '2.7', 'WC_Product::get_name' );
// In order to keep backwards compatibility it's required to use the parent title for variations.
if ( $this->is_type( 'variation' ) ) {
$parent = get_post( $this->get_parent_id() );
$title = $parent ? $parent->post_title : '';
} else {
$title = $this->get_post_data() ? $this->get_post_data()->post_title : '';
}
return apply_filters( 'woocommerce_product_title', $title, $this );
}
/**