Abstract_WC_Order_Data_Store_CPT::delete( WC_Order $order, array $args = array() )
Method to delete an order from the database.
Description Description
Parameters Parameters
- $order
-
(Required) Order object.
- $args
-
(Optional) Array of args to pass to the delete method.
Default value: array()
Return Return
(void)
Source Source
File: includes/data-stores/abstract-wc-order-data-store-cpt.php
public function delete( &$order, $args = array() ) {
$id = $order->get_id();
$args = wp_parse_args(
$args,
array(
'force_delete' => false,
)
);
if ( ! $id ) {
return;
}
if ( $args['force_delete'] ) {
wp_delete_post( $id );
$order->set_id( 0 );
do_action( 'woocommerce_delete_order', $id );
} else {
wp_trash_post( $id );
$order->set_status( 'trash' );
do_action( 'woocommerce_trash_order', $id );
}
}