Deprecate get_title and it's hook, use get_name instead and pull name from parent.
This commit is contained in:
parent
3dd6b483e5
commit
2b464d2e52
|
@ -164,6 +164,22 @@ 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.
|
||||
*
|
||||
|
|
|
@ -1626,15 +1626,6 @@ 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
|
||||
|
|
|
@ -27,6 +27,7 @@ class WC_Product_Variation extends WC_Product_Simple {
|
|||
* @var array
|
||||
*/
|
||||
protected $parent_data = array(
|
||||
'name' => '',
|
||||
'sku' => '',
|
||||
'manage_stock' => '',
|
||||
'stock_quantity' => '',
|
||||
|
@ -64,15 +65,6 @@ 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.
|
||||
*
|
||||
|
@ -120,6 +112,20 @@ class WC_Product_Variation extends WC_Product_Simple {
|
|||
return apply_filters( 'woocommerce_product_add_to_cart_url', $url, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get product name.
|
||||
*
|
||||
* @param string $context
|
||||
* @return string
|
||||
*/
|
||||
public function get_name( $context = 'view' ) {
|
||||
if ( 'view' === $context ) {
|
||||
return $this->parent_data['name'];
|
||||
} else {
|
||||
return $this->get_prop( 'name', $context );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SKU (Stock-keeping unit) - product unique ID.
|
||||
*
|
||||
|
|
|
@ -198,7 +198,7 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl
|
|||
}
|
||||
|
||||
$product->set_parent_data( array(
|
||||
'title' => get_the_title( $product->get_parent_id() ),
|
||||
'name' => 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 ),
|
||||
|
|
|
@ -595,6 +595,7 @@ $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',
|
||||
|
|
Loading…
Reference in New Issue