WC_Order_Data_Store_CPT::read_order_data( WC_Order $order, object $post_object )

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


Description Description


Parameters Parameters

$order

(Required) Order object.

$post_object

(Required) Post object.


Top ↑

Source Source

File: includes/data-stores/class-wc-order-data-store-cpt.php

	protected function read_order_data( &$order, $post_object ) {
		parent::read_order_data( $order, $post_object );
		$id             = $order->get_id();
		$date_completed = get_post_meta( $id, '_date_completed', true );
		$date_paid      = get_post_meta( $id, '_date_paid', true );

		if ( ! $date_completed ) {
			$date_completed = get_post_meta( $id, '_completed_date', true );
		}

		if ( ! $date_paid ) {
			$date_paid = get_post_meta( $id, '_paid_date', true );
		}

		$order->set_props(
			array(
				'order_key'            => get_post_meta( $id, '_order_key', true ),
				'customer_id'          => get_post_meta( $id, '_customer_user', true ),
				'billing_first_name'   => get_post_meta( $id, '_billing_first_name', true ),
				'billing_last_name'    => get_post_meta( $id, '_billing_last_name', true ),
				'billing_company'      => get_post_meta( $id, '_billing_company', true ),
				'billing_address_1'    => get_post_meta( $id, '_billing_address_1', true ),
				'billing_address_2'    => get_post_meta( $id, '_billing_address_2', true ),
				'billing_city'         => get_post_meta( $id, '_billing_city', true ),
				'billing_state'        => get_post_meta( $id, '_billing_state', true ),
				'billing_postcode'     => get_post_meta( $id, '_billing_postcode', true ),
				'billing_country'      => get_post_meta( $id, '_billing_country', true ),
				'billing_email'        => get_post_meta( $id, '_billing_email', true ),
				'billing_phone'        => get_post_meta( $id, '_billing_phone', true ),
				'shipping_first_name'  => get_post_meta( $id, '_shipping_first_name', true ),
				'shipping_last_name'   => get_post_meta( $id, '_shipping_last_name', true ),
				'shipping_company'     => get_post_meta( $id, '_shipping_company', true ),
				'shipping_address_1'   => get_post_meta( $id, '_shipping_address_1', true ),
				'shipping_address_2'   => get_post_meta( $id, '_shipping_address_2', true ),
				'shipping_city'        => get_post_meta( $id, '_shipping_city', true ),
				'shipping_state'       => get_post_meta( $id, '_shipping_state', true ),
				'shipping_postcode'    => get_post_meta( $id, '_shipping_postcode', true ),
				'shipping_country'     => get_post_meta( $id, '_shipping_country', true ),
				'payment_method'       => get_post_meta( $id, '_payment_method', true ),
				'payment_method_title' => get_post_meta( $id, '_payment_method_title', true ),
				'transaction_id'       => get_post_meta( $id, '_transaction_id', true ),
				'customer_ip_address'  => get_post_meta( $id, '_customer_ip_address', true ),
				'customer_user_agent'  => get_post_meta( $id, '_customer_user_agent', true ),
				'created_via'          => get_post_meta( $id, '_created_via', true ),
				'date_completed'       => $date_completed,
				'date_paid'            => $date_paid,
				'cart_hash'            => get_post_meta( $id, '_cart_hash', true ),
				'customer_note'        => $post_object->post_excerpt,
			)
		);
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.