Abstract_WC_Order_Data_Store_CPT::delete()
Method to delete an order from the database.
Method of the class: Abstract_WC_Order_Data_Store_CPT{}
Hooks from the method
Return
null
. Nothing (null).
Usage
$Abstract_WC_Order_Data_Store_CPT = new Abstract_WC_Order_Data_Store_CPT(); $Abstract_WC_Order_Data_Store_CPT->delete( $order, $args );
- $order(WC_Order) (required) (passed by reference — &)
- Order object.
- $args(array)
- Array of args to pass to the delete method.
Default: array()
Abstract_WC_Order_Data_Store_CPT::delete() Abstract WC Order Data Store CPT::delete code WC 9.4.2
public function delete( &$order, $args = array() ) { $id = $order->get_id(); $args = wp_parse_args( $args, array( 'force_delete' => false, 'suppress_filters' => false, ) ); if ( ! $id ) { return; } $do_filters = ! $args['suppress_filters']; if ( $args['force_delete'] ) { if ( $do_filters ) { /** * Fires immediately before an order is deleted from the database. * * @since 8.0.0 * * @param int $order_id ID of the order about to be deleted. * @param WC_Order $order Instance of the order that is about to be deleted. */ do_action( 'woocommerce_before_delete_order', $id, $order ); } wp_delete_post( $id ); $order->set_id( 0 ); if ( $do_filters ) { /** * Fires immediately after an order is deleted. * * @since 2.7.0 * * @param int $order_id ID of the order that has been deleted. */ do_action( 'woocommerce_delete_order', $id ); } } else { if ( $do_filters ) { /** * Fires immediately before an order is trashed. * * @since 8.0.0 * * @param int $order_id ID of the order about to be trashed. * @param WC_Order $order Instance of the order that is about to be trashed. */ do_action( 'woocommerce_before_trash_order', $id, $order ); } wp_trash_post( $id ); $order->set_status( 'trash' ); if ( $do_filters ) { /** * Fires immediately after an order is trashed. * * @since 2.7.0 * * @param int $order_id ID of the order that has been trashed. */ do_action( 'woocommerce_trash_order', $id ); } } }