private function __construct() { if (!class_exists('WooCommerce') or XmlExportEngine::$exportOptions['export_type'] == 'specific' and !in_array('shop_order', XmlExportEngine::$post_types) or XmlExportEngine::$exportOptions['export_type'] == 'advanced' and strpos(XmlExportEngine::$exportOptions['wp_query'], 'shop_order') === false) { self::$is_active = false; return; } $this->filter_sections = array('general' => array('title' => __("Order", "wp_all_export_plugin"), 'fields' => array('ID' => __('Order ID', 'wp_all_export_plugin'), 'cf__order_key' => __('Order Key', 'wp_all_export_plugin'), 'post_date' => __('Order Date', 'wp_all_export_plugin'), 'cf__completed_date' => __('Completed Date', 'wp_all_export_plugin'), 'post_title' => __('Title', 'wp_all_export_plugin'), 'post_status' => __('Order Status', 'wp_all_export_plugin'), 'cf__order_currency' => __('Order Currency', 'wp_all_export_plugin'), 'cf__payment_method_title' => __('Payment Method', 'wp_all_export_plugin'), 'cf__order_total' => __('Order Total', 'wp_all_export_plugin'))), 'customer' => array('title' => __("Customer", "wp_all_export_plugin"), 'fields' => array())); foreach ($this->available_customer_data() as $key => $value) { $this->filter_sections['customer']['fields'][$key == 'post_excerpt' ? $key : 'cf_' . $key] = $value; } if (empty(PMXE_Plugin::$session)) { $id = $_GET['export_id']; $export = new PMXE_Export_Record(); $export->getById($id); if (!$export->isEmpty() and $export->options['export_to'] == 'csv') { $this->init_additional_data(); } } else { self::$orders_data = PMXE_Plugin::$session->get('orders_data'); } add_filter("wp_all_export_available_sections", array(&$this, "filter_available_sections"), 10, 1); add_filter("wp_all_export_available_filter_sections", array(&$this, "filter_available_filter_sections"), 10, 1); add_filter("wp_all_export_init_fields", array(&$this, "filter_init_fields"), 10, 1); add_filter("wp_all_export_filters", array(&$this, "filter_export_filters"), 10, 1); self::$order_sections = $this->available_sections(); }
public function init_additional_data() { if (!self::$is_active) { return; } if (empty(self::$orders_data) or 'PMXE_Admin_Manage' == PMXE_Plugin::getInstance()->getAdminCurrentScreen()->base) { $in_orders = preg_replace("%(SQL_CALC_FOUND_ROWS|LIMIT.*)%", "", XmlExportEngine::$exportQuery->request); self::$orders_data = array(); global $wpdb; $table_prefix = $wpdb->prefix; self::$orders_data['line_items_max_count'] = $wpdb->get_var($wpdb->prepare("SELECT max(cnt) as line_items_count FROM ( \n\t\t\t\t\tSELECT order_id, COUNT(*) as cnt FROM {$table_prefix}woocommerce_order_items \n\t\t\t\t\t\tWHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (" . $in_orders . ") GROUP BY order_id) AS T3", 'line_item')); self::$orders_data['taxes'] = $wpdb->get_results($wpdb->prepare("SELECT order_item_id, order_id, order_item_name FROM {$table_prefix}woocommerce_order_items \n\t\t\t\t\t\tWHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (" . $in_orders . ") GROUP BY order_item_name", 'tax')); self::$orders_data['coupons'] = $wpdb->get_results($wpdb->prepare("SELECT order_item_id, order_id, order_item_name FROM {$table_prefix}woocommerce_order_items \n\t\t\t\t\t\tWHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (" . $in_orders . ") GROUP BY order_item_name", 'coupon')); self::$orders_data['fees'] = $wpdb->get_results($wpdb->prepare("SELECT order_item_id, order_id, order_item_name FROM {$table_prefix}woocommerce_order_items \n\t\t\t\t\t\tWHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (" . $in_orders . ") GROUP BY order_item_name", 'fee')); self::$orders_data['variations'] = $wpdb->get_results($wpdb->prepare("SELECT meta_key FROM {$table_prefix}woocommerce_order_itemmeta \n\t\t\t\t\t\tWHERE {$table_prefix}woocommerce_order_itemmeta.meta_key LIKE %s AND {$table_prefix}woocommerce_order_itemmeta.order_item_id IN (\n\t\t\t\t\t\t\tSELECT {$table_prefix}woocommerce_order_items.order_item_id FROM {$table_prefix}woocommerce_order_items \n\t\t\t\t\t\t\tWHERE {$table_prefix}woocommerce_order_items.order_item_type = %s AND {$table_prefix}woocommerce_order_items.order_id IN (" . $in_orders . ") ) GROUP BY meta_key", 'pa_%', 'line_item')); if (!empty(PMXE_Plugin::$session)) { PMXE_Plugin::$session->set('orders_data', self::$orders_data); PMXE_Plugin::$session->save_data(); } } }