woocommerce_new_coupon_data

The WooCommerce woocommerce new coupon data hook.

Description

apply_filters( 'woocommerce_new_coupon_data', (callback) $array ); 

Parameters (1)

0. $array — Optional. (callback) => array( 'post_type' => 'shop_coupon', 'post_status' => 'publish', 'post_author' => get_current_user_id(), 'post_title' => $coupon->get_code( 'edit' ), 'post_content' => '', 'post_excerpt' => $coupon->get_description( 'edit' ), 'post_date' => gmdate( 'Y-m-d H:i:s', $coupon->get_date_created()->getOffsetTimestamp() ), 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', $coupon->get_date_created()->getTimestamp() ), )
The array.

Usage

To run the hook, copy the example below.
  1. $array = apply_filters( 'woocommerce_new_coupon_data', $array ); 
  2.  
  3. if ( !empty( $array ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_new_coupon_data callback 
  2. function filter_woocommerce_new_coupon_data( $array ) { 
  3. // make filter magic happen here... 
  4. return $array
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'woocommerce_new_coupon_data', 'filter_woocommerce_new_coupon_data', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'woocommerce_new_coupon_data', 'filter_woocommerce_new_coupon_data', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/includes/data-stores/class-wc-coupon-data-store-cpt.php  
  1. $coupon_id = wp_insert_post( apply_filters( 'woocommerce_new_coupon_data', array(