Export button by product
-
Hi!
Is possible to create a Export button that can be clicked to generate a report of all orders for a product in whatever product is in vogue, such as woocommerce reports, product page, sales environment like WCFM, DOKAN, etc …?
Like this:
add_filter( 'post_row_actions', function($actions, $post){ if ( 'product' == $post->post_type ) { $actions['export_orders'] = '<a href="' . wp_nonce_url( admin_url( 'edit.php?post_type=product&action=export_orders&post=' . $post->ID ), 'export-orders-product_' . $post->ID ) . '" rel="permalink">' . esc_html__( 'Export Orders', 'woocommerce' ) . '</a>'; } return $actions; }, 100, 2 ); add_action( 'admin_action_export_orders', function() { $product_id = $_REQUEST['post']; add_filter('woe_settings_validate_defaults', function($settings) use ($product_id){ $settings['products'] = array($product_id); $settings['all_products_from_order'] = 0;// set 1 to export all items from the order! return $settings; }); $_REQUEST['profile'] = 'now'; $ajax_export = new WC_Order_Export_Ajax(); $ajax_export->ajax_run_one_job(); die(); });If not possible,
This link structure (/wp-admin/edit.php?post_type=product&action=export_orders&post=—ID—) could be used in the frontend by set permission?or, like this:
<form method="get" action="/wp-admin/admin-ajax.php"> <input type="hidden" name="action" value="order_exporter"> <input type="hidden" name="method" value="run_one_job"> <input type="hidden" name="profile" value="now"> <input type="submit" name="exportAllOrders" id="exportAllOrders" value="Export"> </form>But in ID, exportAllOrders changes to product-id, allowing a button to export orders by product in any place…
Technically a button that can be clicked to generate a report in any place…
Thanks
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
The topic ‘Export button by product’ is closed to new replies.