WordPress at Your Fingertips
function is not described

WC_Order_Data_Store_CPT::update() public WC 1.0

Method to update an order in the database.

{} It's a method of the class: WC_Order_Data_Store_CPT{}

Return

null. Nothing.

Usage

$WC_Order_Data_Store_CPT = new WC_Order_Data_Store_CPT();
$WC_Order_Data_Store_CPT->update( $order );
$order(WC_Order) (required) (passed by reference — &)
Order object.

Code of WC_Order_Data_Store_CPT::update() WC 5.8.0

public function update( &$order ) {
	// Before updating, ensure date paid is set if missing.
	if ( ! $order->get_date_paid( 'edit' ) && version_compare( $order->get_version( 'edit' ), '3.0', '<' ) && $order->has_status( apply_filters( 'woocommerce_payment_complete_order_status', $order->needs_processing() ? 'processing' : 'completed', $order->get_id(), $order ) ) ) {
		$order->set_date_paid( $order->get_date_created( 'edit' ) );
	}

	// Also grab the current status so we can compare.
	$previous_status = get_post_status( $order->get_id() );

	// Update the order.
	parent::update( $order );

	// Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
	$new_status = $order->get_status( 'edit' );

	if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
		do_action( 'woocommerce_new_order', $order->get_id(), $order );
	} else {
		do_action( 'woocommerce_update_order', $order->get_id(), $order );
	}
}