Adjust how product_type is deprecated

This commit is contained in:
Mike Jolley 2017-02-13 14:31:43 +00:00
parent e71451b2f1
commit bdf567e90d
2 changed files with 8 additions and 9 deletions

View File

@ -17,13 +17,6 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
abstract class WC_Abstract_Legacy_Product extends WC_Data {
/**
* The product's type (simple, variable etc).
* @deprecated 2.7.0 get_type() method should return string instead since this prop should not be changed or be public.
* @var string
*/
public $product_type = 'simple';
/**
* Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past.
*
@ -45,6 +38,7 @@ abstract class WC_Abstract_Legacy_Product extends WC_Data {
'total_stock',
'crosssell_ids',
'parent',
'product_type',
);
if ( $this->is_type( 'variation' ) ) {
$valid = array_merge( $valid, array(
@ -75,6 +69,9 @@ abstract class WC_Abstract_Legacy_Product extends WC_Data {
case 'id' :
$value = $this->is_type( 'variation' ) ? $this->get_parent_id() : $this->get_id();
break;
case 'product_type' :
$value = $this->get_type();
break;
case 'product_attributes' :
$value = isset( $this->data['attributes'] ) ? $this->data['attributes'] : '';
break;

View File

@ -129,12 +129,14 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Get internal type. Should return string and *should be overridden* by child classes.
*
* The product_type property is @deprecated but is used here for BW compat with child classes which may be defining product_type and not have a get_type method.
*
* @since 2.7.0
* @return string
*/
public function get_type() {
// product_type is @deprecated but here for BW compat with child classes.
return $this->product_type;
return isset( $this->product_type ) ? $this->product_type : 'simple';
}
/*