/**
 * Export each order individually when paid
 *
 * @param int $order_id the ID of the order being exported
 */
function sv_wc_csv_export_export_order_on_payment($order_id)
{
    $export = new WC_Customer_Order_CSV_Export_Handler($order_id);
    // for FTP
    $export->upload();
    // uncomment for HTTP POST
    // $export->http_post();
}
コード例 #2
0
 /**
  * Exports any non-exported orders to CSV and performs the chosen action (upload, HTTP POST, email)
  *
  * @since 3.0
  */
 public function auto_export_orders()
 {
     $order_statuses = (array) get_option('wc_customer_order_csv_export_auto_export_statuses');
     /**
      * Query order IDs to export
      *
      * By default we get un-exported order IDs,
      * but this filter can change the query behavior
      *
      * @since 3.11.2
      * @param array $query_args WP_Query args to fetch order IDs to export automatically
      * @param array $order_statuses Order statuses to export
      */
     $query_args = apply_filters('wc_customer_order_csv_export_auto_export_order_query_args', array('fields' => 'ids', 'post_type' => 'shop_order', 'post_status' => empty($order_statuses) ? 'any' : $order_statuses, 'nopaging' => true, 'meta_key' => '_wc_customer_order_csv_export_is_exported', 'meta_value' => 0), $order_statuses);
     $query = new WP_Query($query_args);
     if (!empty($query->posts)) {
         // Export the queried orders
         $export = new WC_Customer_Order_CSV_Export_Handler($query->posts);
         $export->export_via(get_option('wc_customer_order_csv_export_auto_export_method'));
     }
     /**
      * Auto-Export Action.
      *
      * Fired when orders are auto-exported
      *
      * @since 3.0
      * @param array $order_ids order IDs that were exported
      */
     do_action('wc_customer_order_csv_export_orders_exported', $query->posts);
 }
 /**
  * Processes the 'Download to CSV' custom bulk action on the 'Orders' page bulk action drop-down
  *
  * @since 3.0
  */
 public function process_order_bulk_actions()
 {
     global $typenow;
     if ('shop_order' == $typenow) {
         // get the action
         $wp_list_table = _get_list_table('WP_Posts_List_Table');
         $action = $wp_list_table->current_action();
         // return if not processing our actions
         if (!in_array($action, array('download_to_csv', 'mark_exported', 'mark_not_exported'))) {
             return;
         }
         // security check
         check_admin_referer('bulk-posts');
         // make sure order IDs are submitted
         if (isset($_REQUEST['post'])) {
             $order_ids = array_map('absint', $_REQUEST['post']);
         }
         // return if there are no orders to export
         if (empty($order_ids)) {
             return;
         }
         // give ourselves an unlimited timeout if possible
         @set_time_limit(0);
         if ('download_to_csv' == $action) {
             // setup export class
             $export = new WC_Customer_Order_CSV_Export_Handler($order_ids);
             $export->download();
         } else {
             // mark each order as exported / not exported
             foreach ($order_ids as $order_id) {
                 update_post_meta($order_id, '_wc_customer_order_csv_export_is_exported', 'mark_exported' == $action ? 1 : 0);
             }
         }
     }
 }
コード例 #4
0
 /**
  * Downloads order in CSV format (from order action button on 'Orders' page)
  *
  * @since 3.0
  */
 public function process_ajax_export_order()
 {
     if (!is_admin() || !current_user_can('edit_posts')) {
         wp_die(__('You do not have sufficient permissions to access this page.', WC_Customer_Order_CSV_Export::TEXT_DOMAIN));
     }
     if (!check_admin_referer('wc_customer_order_csv_export_export_order')) {
         wp_die(__('You have taken too long, please go back and try again.', WC_Customer_Order_CSV_Export::TEXT_DOMAIN));
     }
     $order_id = !empty($_GET['order_id']) ? absint($_GET['order_id']) : '';
     if (!$order_id) {
         die;
     }
     $export = new WC_Customer_Order_CSV_Export_Handler($order_id);
     $export->download();
     wp_redirect(wp_get_referer());
     exit;
 }
 /**
  * Exports any non-exported orders to CSV and performs the chosen action (upload, HTTP POST, email)
  *
  * @since 3.0
  */
 public function auto_export_orders()
 {
     $order_statuses = (array) get_option('wc_customer_order_csv_export_auto_export_statuses');
     // get un-exported order IDs
     $query_args = array('fields' => 'ids', 'post_type' => 'shop_order', 'post_status' => empty($order_statuses) ? 'any' : $order_statuses, 'nopaging' => true, 'meta_key' => '_wc_customer_order_csv_export_is_exported', 'meta_value' => 0);
     $query = new WP_Query($query_args);
     if (!empty($query->posts)) {
         // export them!
         $export = new WC_Customer_Order_CSV_Export_Handler($query->posts);
         $export->export_via(get_option('wc_customer_order_csv_export_auto_export_method'));
     }
     /**
      * Auto-Export Action.
      *
      * Fired when orders are auto-exported
      *
      * @since 3.0
      * @param array $order_ids order IDs that were exported
      */
     do_action('wc_customer_order_csv_export_orders_exported', $query->posts);
 }