Add product export row action hook
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; } ```
This commit is contained in:
parent
906efe1ffc
commit
865efa3736
|
@ -69,6 +69,7 @@ $total_rows = $product_count->publish + $product_count->private + $variatio
|
|||
<label for="woocommerce-exporter-meta"><?php esc_html_e( 'Yes, export all custom meta', 'woocommerce' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php do_action( 'woocommerce_product_export_row' ); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<progress class="woocommerce-exporter-progress" max="100" value="0"></progress>
|
||||
|
|
Loading…
Reference in New Issue