Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableDataStore::update_order_from_object()
Updates an order (in this datastore) from another order object.
Method of the class: OrdersTableDataStore{}
No Hooks.
Return
true|false
. Whether the order was updated.
Usage
$OrdersTableDataStore = new OrdersTableDataStore(); $OrdersTableDataStore->update_order_from_object( $order );
- $order(\WC_Abstract_Order) (required)
- Source order.
OrdersTableDataStore::update_order_from_object() OrdersTableDataStore::update order from object code WC 9.3.3
public function update_order_from_object( $order ) { $hpos_order = new \WC_Order(); $hpos_order->set_id( $order->get_id() ); $this->read( $hpos_order ); $hpos_order->set_props( $order->get_data() ); // Meta keys. foreach ( $hpos_order->get_meta_data() as &$meta ) { $hpos_order->delete_meta_data( $meta->key ); } foreach ( $order->get_meta_data() as &$meta ) { $hpos_order->add_meta_data( $meta->key, $meta->value ); } add_filter( 'woocommerce_orders_table_datastore_should_save_after_meta_change', '__return_false' ); $hpos_order->save_meta_data(); remove_filter( 'woocommerce_orders_table_datastore_should_save_after_meta_change', '__return_false' ); $db_rows = $this->get_db_rows_for_order( $hpos_order, 'update', true ); foreach ( $db_rows as $db_update ) { ksort( $db_update['data'] ); ksort( $db_update['format'] ); $this->persist_db_row( $db_update ); } return true; }