Abstract_WC_Order_Item_Type_Data_Store::delete()
Remove an order item from the database.
Method of the class: Abstract_WC_Order_Item_Type_Data_Store{}
Hooks from the method
Return
null
. Nothing (null).
Usage
$Abstract_WC_Order_Item_Type_Data_Store = new Abstract_WC_Order_Item_Type_Data_Store(); $Abstract_WC_Order_Item_Type_Data_Store->delete( $item, $args );
- $item(WC_Order_Item) (required) (passed by reference — &)
- Order item object.
- $args(array)
- Array of args to pass to the delete method.
Default: array()
Changelog
Since 3.0.0 | Introduced. |
Abstract_WC_Order_Item_Type_Data_Store::delete() Abstract WC Order Item Type Data Store::delete code WC 9.4.2
public function delete( &$item, $args = array() ) { if ( $item->get_id() ) { global $wpdb; do_action( 'woocommerce_before_delete_order_item', $item->get_id() ); $wpdb->delete( $wpdb->prefix . 'woocommerce_order_items', array( 'order_item_id' => $item->get_id() ) ); $wpdb->delete( $wpdb->prefix . 'woocommerce_order_itemmeta', array( 'order_item_id' => $item->get_id() ) ); do_action( 'woocommerce_delete_order_item', $item->get_id() ); $this->clear_cache( $item ); } }