WC_Order_Data_Store_CPT::update_order_from_object()publicWC 1.0

Given an initialized order object, update the post/postmeta records.

{} Это метод класса: WC_Order_Data_Store_CPT{}

Хуков нет.

Возвращает

true|false. Whether the order was updated.

Использование

$WC_Order_Data_Store_CPT = new WC_Order_Data_Store_CPT();
$WC_Order_Data_Store_CPT->update_order_from_object( $order );
$order(WC_Order) (обязательный)
Order object.

Код WC_Order_Data_Store_CPT::update_order_from_object() WC 6.9.4

public function update_order_from_object( $order ) {
	if ( ! $order->get_id() ) {
		return false;
	}
	$this->update_order_meta_from_object( $order );
	return wp_update_post(
		array(
			'ID'            => $order->get_id(),
			'post_date'     => gmdate( 'Y-m-d H:i:s', $order->get_date_created( 'edit' )->getOffsetTimestamp() ),
			'post_date_gmt' => gmdate( 'Y-m-d H:i:s', $order->get_date_created( 'edit' )->getTimestamp() ),
			'post_status'   => $this->get_post_status( $order ),
			'post_parent'   => $order->get_parent_id(),
			'post_excerpt'  => $this->get_post_excerpt( $order ),
			'post_type'     => 'shop_order',
		)
	);
}