Bake out of get_title deprecation changes

This commit is contained in:
Justin Shreve 2017-01-26 07:46:59 -08:00
parent 318046789c
commit 7b1adfb98f
5 changed files with 20 additions and 19 deletions

View File

@ -164,22 +164,6 @@ abstract class WC_Abstract_Legacy_Product extends WC_Data {
return $this->get_gallery_image_ids();
}
/**
* Get the product's title.
*
* @deprecated 2.7.0
* @return string
*/
public function get_title() {
wc_deprecated_function( 'WC_Product::get_title', '2.7', 'WC_Product::get_name' );
if ( $this->is_type( 'variation' ) ) {
return apply_filters( 'woocommerce_product_title', $this->parent_data['name'], $this );
}
return apply_filters( 'woocommerce_product_title', $this->get_name(), $this );
}
/**
* Set stock level of the product.
*

View File

@ -1626,6 +1626,15 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|--------------------------------------------------------------------------
*/
/**
* Get the product's title. For products this is the product name.
*
* @return string
*/
public function get_title() {
return apply_filters( 'woocommerce_product_title', $this->get_name(), $this );
}
/**
* Product permalink.
* @return string

View File

@ -64,6 +64,15 @@ class WC_Product_Variation extends WC_Product_Simple {
return 'parent' === $this->get_manage_stock() ? $this->get_parent_id() : $this->get_id();
}
/**
* Get the product's title. For variations this is the parent product name.
*
* @return string
*/
public function get_title() {
return apply_filters( 'woocommerce_product_title', $this->parent_data['title'], $this );
}
/**
* Get variation attribute values. Keys are prefixed with attribute_, as stored.
*

View File

@ -77,7 +77,7 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl
*/
if ( __( 'Variation #', 'woocommerce' ) === substr( $product_name, 0, 11 ) || ( 'Product #' . $product->get_parent_id() . ' Variation' ) === $product_name ) {
$parent_data = $product->get_parent_data();
$new_title = $parent_data['name'] . ' – ' . wc_get_formatted_variation( $product, true, false );
$new_title = $parent_data['title'] . ' – ' . wc_get_formatted_variation( $product, true, false );
$product->set_name( $new_title );
wp_update_post( array(
'ID' => $product->get_id(),
@ -215,7 +215,7 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl
}
$product->set_parent_data( array(
'name' => get_the_title( $product->get_parent_id() ),
'title' => get_the_title( $product->get_parent_id() ),
'sku' => get_post_meta( $product->get_parent_id(), '_sku', true ),
'manage_stock' => get_post_meta( $product->get_parent_id(), '_manage_stock', true ),
'backorders' => get_post_meta( $product->get_parent_id(), '_backorders', true ),

View File

@ -595,7 +595,6 @@ $wc_map_deprecated_filters = array(
'woocommerce_product_get_gallery_image_ids' => 'woocommerce_product_gallery_attachment_ids',
'woocommerce_product_get_review_count' => 'woocommerce_product_review_count',
'woocommerce_product_get_downloads' => 'woocommerce_product_files',
'woocommerce_product_get_name' => 'woocommerce_product_title',
'woocommerce_order_get_currency' => 'woocommerce_get_currency',
'woocommerce_order_get_discount_total' => 'woocommerce_order_amount_discount_total',
'woocommerce_order_get_discount_tax' => 'woocommerce_order_amount_discount_tax',