WC_Coupon_Data_Store_CPT::delete( WC_Coupon $coupon, array $args = array() )
Deletes a coupon from the database.
Description Description
Parameters Parameters
- $coupon
-
(Required) Coupon object.
- $args
-
(Optional) Array of args to pass to the delete method.
Default value: array()
Source Source
File: includes/data-stores/class-wc-coupon-data-store-cpt.php
public function delete( &$coupon, $args = array() ) {
$args = wp_parse_args(
$args,
array(
'force_delete' => false,
)
);
$id = $coupon->get_id();
if ( ! $id ) {
return;
}
if ( $args['force_delete'] ) {
wp_delete_post( $id );
wp_cache_delete( WC_Cache_Helper::get_cache_prefix( 'coupons' ) . 'coupon_id_from_code_' . $coupon->get_code(), 'coupons' );
$coupon->set_id( 0 );
do_action( 'woocommerce_delete_coupon', $id );
} else {
wp_trash_post( $id );
do_action( 'woocommerce_trash_coupon', $id );
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |