Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
having this hook is possible to actually use the woocommerce_product_export_product_query_args filter ``` add_action('woocommerce_product_export_row', 'export_custom_product'); add_filter( 'woocommerce_product_export_product_query_args', 'export_product_query_args'); // https://github.com/woocommerce/woocommerce/wiki/wc_get_products-and-WC_Product_Query add_filter( 'woocommerce_product_data_store_cpt_get_products_query', 'handle_custom_query_var', 10, 2 ); function export_custom_product() { $args = [ 'show_option_all' => 'Custom', 'taxonomy' => 'pa_custom', 'name' => 'custom', 'orderby' => 'name', 'order' => 'ASC', 'selected' => isset($_REQUEST['custom']) ? $_REQUEST['custom'] : '', 'show_count' => true, 'hide_empty' => true, 'menu_order' => false ]; ?> <tr> <th scope="row"> <label for="custom">Filter by Custom</label> </th> <td> <?php wp_dropdown_categories($args); ?> </td> </tr> <?php } function export_product_query_args($args) { $args['custom'] = 'default'; if ( ! empty( $_POST['form'] ) ) { $values = explode('=', $_POST['form']); if('custom' === $values[0]) { $args['custom'] = wp_unslash( $values[1] ); } } return $args; } function handle_custom_query_var( $query, $query_vars ) { if ( ! empty( $query_vars['custom'] ) ) { $query['tax_query'][] = array( 'taxonomy' => 'pa_ custom', 'field' => 'id', 'terms' => esc_attr( $query_vars['custom'] ) ); } return $query; } ```
- Loading branch information