Merge pull request #12971 from thenbrent/add_read_extra_data

Add WC_Product_Data_Store_CPT::read_extra_data()
This commit is contained in:
Mike Jolley 2017-01-25 00:08:18 +00:00 committed by GitHub
commit 76f5bc9b79
2 changed files with 10 additions and 2 deletions

View File

@ -136,6 +136,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
$this->read_downloads( $product ); $this->read_downloads( $product );
$this->read_visibility( $product ); $this->read_visibility( $product );
$this->read_product_data( $product ); $this->read_product_data( $product );
$this->read_extra_data( $product );
$product->set_object_read( true ); $product->set_object_read( true );
} }
@ -260,9 +261,15 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
'download_expiry' => get_post_meta( $id, '_download_expiry', true ), 'download_expiry' => get_post_meta( $id, '_download_expiry', true ),
'image_id' => get_post_thumbnail_id( $id ), 'image_id' => get_post_thumbnail_id( $id ),
) ); ) );
}
// Gets extra data associated with the product. /**
// Like button text or product URL for external products. * Read extra data associated with the product, like button text or product URL for external products.
*
* @param WC_Product
* @since 2.7.0
*/
protected function read_extra_data( &$product ) {
foreach ( $product->get_extra_data_keys() as $key ) { foreach ( $product->get_extra_data_keys() as $key ) {
$function = 'set_' . $key; $function = 'set_' . $key;
if ( is_callable( array( $product, $function ) ) ) { if ( is_callable( array( $product, $function ) ) ) {

View File

@ -66,6 +66,7 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl
) ); ) );
$this->read_product_data( $product ); $this->read_product_data( $product );
$this->read_extra_data( $product );
$product->set_attributes( wc_get_product_variation_attributes( $product->get_id() ) ); $product->set_attributes( wc_get_product_variation_attributes( $product->get_id() ) );
// Set object_read true once all data is read. // Set object_read true once all data is read.