WC_Product_Data_Store_CPT::read_extra_data()protectedWC 3.0.0

Read extra data associated with the product, like button text or product URL for external products.

Method of the class: WC_Product_Data_Store_CPT{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->read_extra_data( $product );
$product(WC_Product) (required) (passed by reference — &)
Product object.

Changelog

Since 3.0.0 Introduced.

WC_Product_Data_Store_CPT::read_extra_data() code WC 9.4.2

protected function read_extra_data( &$product ) {
	foreach ( $product->get_extra_data_keys() as $key ) {
		$function = 'set_' . $key;
		if ( is_callable( array( $product, $function ) ) ) {
			$product->{$function}( get_post_meta( $product->get_id(), '_' . $key, true ) );
		}
	}
}