woocommerce_report_out_of_stock_query_from

The WooCommerce woocommerce report out of stock query from hook.

Description

Parameters (1)

0. $from_wpdb_posts_as_posts_inner_join_wpdb_postmeta_as_postmeta_on_posts_id_postmeta_post_id_inner_join_wpdb_postmeta_as_postmeta2_on_posts_id_postmeta2_post_id_where_1_1_and_posts_post_type_in_product_product_variation_and_posts_post_status_publish_and_postmeta2_meta_key_manage_stock_and_postmeta2_meta_value_yes_and_postmeta_meta_key_stock_and_cast_postmeta_meta_value_as_signed_stock — Optional. (string) => "FROM {$wpdb->posts} as posts INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id WHERE 1=1 AND posts.post_type IN ( 'product', 'product_variation' ) AND posts.post_status = 'publish' AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes' AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$stock}' "
The from wpdb posts as posts inner join wpdb postmeta as postmeta on posts id postmeta post id inner join wpdb postmeta as postmeta2 on posts id postmeta2 post id where 1 1 and posts post type in product product variation and posts post status publish and postmeta2 meta key manage stock and postmeta2 meta value yes and postmeta meta key stock and cast postmeta meta value as signed stock.

Usage

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

Defined (2)

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

/includes/admin/reports/class-wc-report-out-of-stock.php  
  1. $query_from = apply_filters( 'woocommerce_report_out_of_stock_query_from', "FROM {$wpdb->posts} as posts 
/includes/admin/class-wc-admin-dashboard.php  
  1. $query_from = apply_filters( 'woocommerce_report_out_of_stock_query_from', "FROM {$wpdb->posts} as posts