WC_Product_Variable_Data_Store_CPT::read_product_dataprotectedWC 3.0.0

Read product data.

Method of the class: WC_Product_Variable_Data_Store_CPT{}

No Hooks.

Returns

null. Nothing (null).

Usage

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

Changelog

Since 3.0.0 Introduced.

WC_Product_Variable_Data_Store_CPT::read_product_data() code WC 10.8.1

protected function read_product_data( &$product ) {
	// Prime caches to reduce future queries.
	$product_id = $product->get_id();
	wp_prime_option_caches(
		array(
			'_transient_wc_var_prices_' . $product_id,
			'_transient_timeout_wc_var_prices_' . $product_id,
			'_transient_wc_product_children_' . $product_id,
			'_transient_timeout_wc_product_children_' . $product_id,
		)
	);

	parent::read_product_data( $product );

	// Make sure data which does not apply to variables is unset.
	$product->set_regular_price( '' );
	$product->set_sale_price( '' );
}