WC_Order_Data_Store_CPT::read_order_data()
Read order data. Can be overridden by child classes to load other props.
Method of the class: 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. |
WC_Order_Data_Store_CPT::read_order_data() WC Order Data Store CPT::read order data code WC 9.4.2
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 ), 'shipping_phone' => get_post_meta( $id, '_shipping_phone', 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, // Operational data props. 'order_stock_reduced' => get_post_meta( $id, '_order_stock_reduced', true ), 'download_permissions_granted' => get_post_meta( $id, '_download_permissions_granted', true ), 'new_order_email_sent' => get_post_meta( $id, '_new_order_email_sent', true ), 'recorded_sales' => wc_string_to_bool( get_post_meta( $id, '_recorded_sales', true ) ), 'recorded_coupon_usage_counts' => get_post_meta( $id, '_recorded_coupon_usage_counts', true ), ) ); }