woocommerce_new_product_data

The WooCommerce woocommerce new product data hook.

Description

apply_filters( 'woocommerce_new_product_data', (callback) $product_get_status ); 

Parameters (1)

0. $product_get_status — Optional. (callback) => array( 'post_type' => 'product', 'post_status' => $product->get_status() ? $product->get_status() : 'publish', 'post_author' => get_current_user_id(), 'post_title' => $product->get_name() ? $product->get_name() : __( 'Product', 'woocommerce' ), 'post_content' => $product->get_description(), 'post_excerpt' => $product->get_short_description(), 'post_parent' => $product->get_parent_id(), 'comment_status' => $product->get_reviews_allowed() ? 'open' : 'closed', 'ping_status' => 'closed', 'menu_order' => $product->get_menu_order(), 'post_date' => gmdate( 'Y-m-d H:i:s', $product->get_date_created( 'edit' )->getOffsetTimestamp() ), 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', $product->get_date_created( 'edit' )->getTimestamp() ), 'post_name' => $product->get_slug( 'edit' ), )
The array.

Usage

To run the hook, copy the example below.
  1. $product_get_status = apply_filters( 'woocommerce_new_product_data', $product_get_status ); 
  2.  
  3. if ( !empty( $product_get_status ) ) { 
  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_product_data callback 
  2. function filter_woocommerce_new_product_data( $product_get_status ) { 
  3. // make filter magic happen here... 
  4. return $product_get_status
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'woocommerce_new_product_data', 'filter_woocommerce_new_product_data', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'woocommerce_new_product_data', 'filter_woocommerce_new_product_data', 10, 1 ); 

Defined (1)

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

/includes/data-stores/class-wc-product-data-store-cpt.php  
  1. $id = wp_insert_post( apply_filters( 'woocommerce_new_product_data', array(