Abstract_WC_Order_Data_Store_CPT::read_order_data()protectedWC 3.0.0

Read order data. Can be overridden by child classes to load other props.

Method of the class: Abstract_WC_Order_Data_Store_CPT{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->read_order_data( $order, $post_object );
$order(WC_Order) (required) (passed by reference — &)
Order object.
$post_object(object) (required)
Post object.

Changelog

Since 3.0.0 Introduced.

Abstract_WC_Order_Data_Store_CPT::read_order_data() code WC 9.4.2

protected function read_order_data( &$order, $post_object ) {
	$id = $order->get_id();

	$this->set_order_props(
		$order,
		array(
			'currency'           => get_post_meta( $id, '_order_currency', true ),
			'discount_total'     => get_post_meta( $id, '_cart_discount', true ),
			'discount_tax'       => get_post_meta( $id, '_cart_discount_tax', true ),
			'shipping_total'     => get_post_meta( $id, '_order_shipping', true ),
			'shipping_tax'       => get_post_meta( $id, '_order_shipping_tax', true ),
			'cart_tax'           => get_post_meta( $id, '_order_tax', true ),
			'total'              => get_post_meta( $id, '_order_total', true ),
			'version'            => get_post_meta( $id, '_order_version', true ),
			'prices_include_tax' => metadata_exists( 'post', $id, '_prices_include_tax' ) ? 'yes' === get_post_meta( $id, '_prices_include_tax', true ) : 'yes' === get_option( 'woocommerce_prices_include_tax' ),
		)
	);

	// Gets extra data associated with the order if needed.
	foreach ( $order->get_extra_data_keys() as $key ) {
		$function = 'set_' . $key;
		if ( is_callable( array( $order, $function ) ) ) {
			$order->{$function}( get_post_meta( $order->get_id(), '_' . $key, true ) );
		}
	}
}