WC_Abstract_Order::save_items()
Save all order items which are part of this order.
Method of the class: WC_Abstract_Order{}
No Hooks.
Return
null
. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->save_items();
WC_Abstract_Order::save_items() WC Abstract Order::save items code WC 8.7.0
protected function save_items() { $items_changed = false; foreach ( $this->items_to_delete as $item ) { $item->delete(); $items_changed = true; } $this->items_to_delete = array(); // Add/save items. foreach ( $this->items as $item_group => $items ) { if ( is_array( $items ) ) { $items = array_filter( $items ); foreach ( $items as $item_key => $item ) { $item->set_order_id( $this->get_id() ); $item_id = $item->save(); // If ID changed (new item saved to DB)... if ( $item_id !== $item_key ) { $this->items[ $item_group ][ $item_id ] = $item; unset( $this->items[ $item_group ][ $item_key ] ); $items_changed = true; } } } } if ( $items_changed ) { delete_transient( 'wc_order_' . $this->get_id() . '_needs_processing' ); } }