Changeset 2745695
- Timestamp:
- 06/21/2022 07:34:33 AM (2 years ago)
- Location:
- woo-order-export
- Files:
-
- 48 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
woo-order-export/trunk/class-woo-order-export.php
r2081193 r2745695 1 1 <?php 2 2 3 class Woo_Order_Export { 4 public function __construct() { 5 add_action( 'admin_menu', array( $this, 'add_page_link' ) ); 6 add_action( 'wp_ajax_order_file_download', array( $this, 'order_file_download' ) ); 7 add_action( 'wp_ajax_nopriv_order_file_download', array( $this, 'order_file_download' ) ); 8 add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); 9 10 } 11 12 public function add_page_link() { 13 $page = add_submenu_page( 'woocommerce', esc_html__( 'Orders Export', 'woo-order-export' ), esc_html__( 'Orders Export', 'woo-order-export' ), 'edit_posts', 'order_exports', array( 3 class Woo_Order_Export 4 { 5 public function __construct () 6 { 7 add_action( 'admin_menu', [ $this, 'add_page_link' ] ); 8 add_action( 'wp_ajax_order_file_download', [ $this, 'order_file_download' ] ); 9 add_action( 'wp_ajax_nopriv_order_file_download', [ $this, 'order_file_download' ] ); 10 add_action( 'admin_print_scripts', [ $this, 'enqueue_scripts' ] ); 11 12 } 13 14 public function add_page_link () 15 { 16 $page = add_submenu_page( 'woocommerce', esc_html__( 'Orders Export', 'woo-order-export' ), esc_html__( 'Orders Export', 'woo-order-export' ), 'edit_posts', 'order_exports', [ 14 17 $this, 15 18 'add_form' 16 ) ); 17 } 18 19 public function add_form() { 19 ] ); 20 } 21 22 public function add_form () 23 { 20 24 ?> 21 25 <div class="container"> … … 24 28 <div class="row"> 25 29 <div class="col-25"> 26 <label for="f date"><?php esc_html_e( 'Start Date', 'woo-order-export' ) ?>:</label>30 <label for="fdate"><?php esc_html_e( 'Start Date', 'woo-order-export' ) ?>:</label> 27 31 </div> 28 32 <div class="col-75"> … … 32 36 <div class="row"> 33 37 <div class="col-25"> 34 <label for="t date"><?php esc_html_e( 'End Date', 'woo-order-export' ) ?>:</label>38 <label for="tdate"><?php esc_html_e( 'End Date', 'woo-order-export' ) ?>:</label> 35 39 </div> 36 40 <div class="col-75"> … … 40 44 <div class="row"> 41 45 <div class="col-25"> 42 <label for=" country"><?php esc_html_e( 'Order Status', 'woo-order-export' ) ?>:</label>46 <label for=""><?php esc_html_e( 'Order Status', 'woo-order-export' ) ?>:</label> 43 47 </div> 44 48 <div class="col-75"> … … 63 67 } 64 68 65 public function get_order_ids( $data_q = array() ) { 69 public function get_order_ids ( $data_q = [] ) 70 { 66 71 $ids = []; 67 72 $args = [ 'date_created' => $data_q[ 0 ] . '...' . $data_q[ 1 ], 'status' => $data_q[ 2 ] ]; … … 76 81 } 77 82 78 public function get_orders_detail( $ids ) { 83 public function get_orders_detail ( $ids ) 84 { 79 85 $data_array = []; 80 86 if ( ! empty( $ids ) ) { … … 88 94 } 89 95 $oder_date = $order->get_date_created(); 90 $data_array[] = array(96 $data_array[] = 91 97 'order_id' => $order->get_id(), 92 98 'date' => $oder_date->date( 'm/d/Y' ), … … 118 124 'currency' => html_entity_decode( $order->get_currency() ), 119 125 'total_price' => $order->get_total(), 120 );126 ; 121 127 } 122 128 } … … 125 131 } 126 132 127 public function order_file_download() { 133 public function order_file_download () 134 { 128 135 check_ajax_referer( 'order_file_download', 'export_orders_ref' ); 129 136 $from_data = sanitize_text_field( $_POST[ 'from_date' ] ); … … 132 139 if ( empty( $from_data ) && empty( $to_date ) && empty( $order_status ) ) { 133 140 exit( esc_html__( 'Data is not verified...', 'woo-order-export' ) ); 134 } else { 135 $ids = $this->get_order_ids( [ $from_data, $to_date, $order_status ] ); 136 $orders = $this->get_orders_detail( $ids ); 137 if ( empty( $orders ) ) { 138 return; 139 } else { 140 $url = $this->get_csv( $orders ); 141 exit( $url ); 142 } 143 } 144 145 } 146 147 public function get_csv( $report_data ) { 141 } 142 143 $ids = $this->get_order_ids( [ $from_data, $to_date, $order_status ] ); 144 $orders = $this->get_orders_detail( $ids ); 145 if ( empty( $orders ) ) { 146 return; 147 } 148 149 $url = $this->get_csv( $orders ); 150 exit( $url ); 151 152 } 153 154 public function get_csv ( $report_data ) 155 { 148 156 $csv_file_name = 'order-report-' . time() . '.csv'; 149 157 $dir = wp_get_upload_dir()[ 'basedir' ] . '/woo-roder-export'; … … 171 179 } 172 180 173 public function enqueue_scripts() { 181 public function enqueue_scripts () 182 { 174 183 $screen = get_current_screen(); 175 184 if ( strpos( $screen->id, 'woocommerce_page_order_exports' ) === false ) { -
woo-order-export/trunk/includes/front-end/classes/class-woo-order-export.php
r2171144 r2745695 1 1 <?php 2 2 3 class Woo_Order_Export { 4 public function __construct() { 5 add_action( 'admin_menu', array( $this, 'woe_add_page_link' ) ); 6 add_action( 'wp_ajax_woe_order_file_download', array( $this, 'woe_order_file_download' ) ); 7 add_action( 'wp_ajax_nopriv_woe_order_file_download', array( $this, 'woe_order_file_download' ) ); 3 class Woo_Order_Export 4 { 5 public function __construct () 6 { 7 add_action( 'admin_menu', [ $this, 'woe_add_page_link' ] ); 8 add_action( 'wp_ajax_woe_order_file_download', [ $this, 'woe_order_file_download' ] ); 9 add_action( 'wp_ajax_nopriv_woe_order_file_download', [ $this, 'woe_order_file_download' ] ); 8 10 //add_action( 'admin_print_scripts', array( $this, 'woe_enqueue_scripts' ) ); 9 11 10 12 } 11 13 12 public function woe_add_page_link() { 13 $page = add_submenu_page( 'woocommerce', esc_html__( 'Orders Export', 'woo-order-export' ), esc_html__( 'Orders Export', 'woo-order-export' ), 'edit_posts', 'order_exports', array( 14 public function woe_add_page_link () 15 { 16 $page = add_submenu_page( 'woocommerce', esc_html__( 'Orders Export', 'woo-order-export' ), esc_html__( 'Orders Export', 'woo-order-export' ), 'edit_posts', 'order_exports', [ 14 17 $this, 15 18 'woe_add_form', 16 ) ); 17 add_action( "admin_print_scripts-$page", array( $this, 'woe_enqueue_scripts' ) ); 18 } 19 20 public function woe_add_form() { 19 ] ); 20 add_action( "admin_print_scripts-$page", [ $this, 'woe_enqueue_scripts' ] ); 21 } 22 23 public function woe_add_form () 24 { 21 25 ?> 22 26 <div class="container"> … … 99 103 } 100 104 101 public function woe_get_order_ids( $data_q = array() ) { 105 public function woe_get_order_ids ( $data_q = [] ) 106 { 102 107 $ids = []; 103 108 $args = [ 104 'date_created' => $data_q[ 0] . '...' . $data_q[1],105 'status' => $data_q[ 2],106 'order' => $data_q[ 3],107 'orderby' => $data_q[ 4],109 'date_created' => $data_q[], 110 'status' => $data_q[], 111 'order' => $data_q[], 112 'orderby' => $data_q[], 108 113 ]; 109 if ( ! empty( $data_q[ 5] ) ) {110 $args[ 'customer'] = $data_q[5];114 if ( ! empty( $data_q[] ) ) { 115 $args[]; 111 116 } 112 117 $order_get = wc_get_orders( $args ); … … 120 125 } 121 126 122 public function woe_get_orders_detail( $ids ) { 127 public function woe_get_orders_detail ( $ids ) 128 { 123 129 $data_array = []; 124 130 if ( ! empty( $ids ) ) { … … 132 138 } 133 139 $oder_date = $order->get_date_created(); 134 $data_array[] = array(140 $data_array[] = 135 141 'order_id' => $order->get_id(), 136 142 'date' => $oder_date->date( 'm/d/Y' ), … … 162 168 'currency' => html_entity_decode( $order->get_currency() ), 163 169 'total_price' => $order->get_total(), 164 );170 ; 165 171 } 166 172 } … … 169 175 } 170 176 171 public function woe_order_file_download() { 177 public function woe_order_file_download () 178 { 172 179 check_ajax_referer( 'woe_order_file_download', 'export_orders_ref' ); 173 $from_data = sanitize_text_field( $_POST[ 'from_date'] );174 $to_date = sanitize_text_field( $_POST[ 'to_date'] );175 $order_status = sanitize_text_field( $_POST[ 'order_status'] );176 $order = sanitize_text_field( $_POST[ 'order'] );177 $orderby = sanitize_text_field( $_POST[ 'orderby'] );178 $email = sanitize_text_field( $_POST[ 'custom_address'] );180 $from_data = sanitize_text_field( $_POST[] ); 181 $to_date = sanitize_text_field( $_POST[] ); 182 $order_status = sanitize_text_field( $_POST[] ); 183 $order = sanitize_text_field( $_POST[] ); 184 $orderby = sanitize_text_field( $_POST[] ); 185 $email = sanitize_text_field( $_POST[] ); 179 186 if ( empty( $from_data ) && empty( $to_date ) && empty( $order_status ) ) { 180 187 exit( esc_html__( 'Data is not verified...', 'woo-order-export' ) ); … … 192 199 } 193 200 194 public function woe_get_csv( $report_data ) { 201 public function woe_get_csv ( $report_data ) 202 { 195 203 $csv_file_name = 'order-report-' . time() . '.csv'; 196 $dir = wp_get_upload_dir()[ 'basedir'] . '/woo-roder-export';204 $dir = wp_get_upload_dir()[] . '/woo-roder-export'; 197 205 $file_dir_set = $dir . '/' . $csv_file_name; 198 206 $fop = @fopen( $file_dir_set, 'w' ); … … 211 219 fclose( $fop ); 212 220 213 if ( ! file_exists( wp_get_upload_dir()[ 'basedir'] . '/woo-roder-export/' . $csv_file_name ) ) {221 if ( ! file_exists( wp_get_upload_dir()[] . '/woo-roder-export/' . $csv_file_name ) ) { 214 222 return; 215 223 } 216 224 217 return wp_get_upload_dir()['baseurl'] . '/woo-roder-export/' . $csv_file_name; 218 } 219 220 public function woe_enqueue_scripts() { 221 222 wp_enqueue_style( 'jquery-ui-datepicker-css', WOE_PLUGIN_FILE . 'assets/css/jquery-ui.min.css', '', WOE_PLUGIN_DETAIL['Version'], 'all' ); 223 wp_enqueue_style( 'woo-order-export', WOE_PLUGIN_FILE . 'assets/css/woo-order-export.css', '', WOE_PLUGIN_DETAIL['Version'], 'all' ); 225 return wp_get_upload_dir()[ 'baseurl' ] . '/woo-roder-export/' . $csv_file_name; 226 } 227 228 public function woe_enqueue_scripts () 229 { 230 231 wp_enqueue_style( 'jquery-ui-datepicker-css', WOE_PLUGIN_FILE . 'assets/css/jquery-ui.min.css', '', WOE_PLUGIN_DETAIL[ 'Version' ], 'all' ); 232 wp_enqueue_style( 'woo-order-export', WOE_PLUGIN_FILE . 'assets/css/woo-order-export.css', '', WOE_PLUGIN_DETAIL[ 'Version' ], 'all' ); 224 233 225 234 $script = 'jQuery(document).ready(function($){ … … 236 245 } 237 246 } 247 248 -
woo-order-export/trunk/index.php
r2171144 r2745695 2 2 /** 3 3 * Plugin Name: Woo Order Export 4 * Plugin URI: https:// demo.themecat.org/woo-order-export5 * Description: Woo Order Export isused to export the WooCommerce orders with all details. It has the option to export the order from a selectable date range and order status base.6 * Version: 2.0 7 * Author: Themecat_Info8 * Author URI: https:// themecat.org/4 * Plugin URI: https:// 5 * Description: Woo Order Export used to export the WooCommerce orders with all details. It has the option to export the order from a selectable date range and order status base. 6 * Version: 2.0 7 * Author: 8 * Author URI: https://.org/ 9 9 * Text Domain: woo-order-export 10 10 * Requires at least: 4.5 11 * Tested up to: 5.211 * Tested up to: 12 12 * License: GPLv2 or later 13 13 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 14 14 * Domain Path: /languages/ 15 15 * WC requires at least: 3.0.0 16 * WC tested up to: 3.616 * WC tested up to: 17 17 */ 18 18 … … 23 23 /** 24 24 * Define the plugin directory url in http:// or https:// base 25 25 26 * @since 1.0.0 26 27 */ … … 31 32 /** 32 33 * Define the plugin directory path 34 33 35 * @since 1.0.0 34 36 */ … … 39 41 /** 40 42 * Define the plugin data info 43 41 44 * @since 1.0.0 42 45 */ … … 50 53 /** 51 54 * The notification html 55 56 52 57 * @since 1.0.0 53 * @return string return the html of notifaction.54 58 */ 55 59 if ( ! function_exists( 'woo_order_export_swatches_wc_notice' ) ) { 56 function woo_order_export_swatches_wc_notice() { 60 function woo_order_export_swatches_wc_notice () 61 { 57 62 ?> 58 63 <div class="error"> … … 65 70 /** 66 71 * Hook the notification 72 73 67 74 * @since 1.0.0 68 * @return void.69 75 */ 70 76 if ( ! function_exists( 'woo_order_export_swatches_constructor' ) ) { 71 function woo_order_export_swatches_constructor() { 77 function woo_order_export_swatches_constructor () 78 { 72 79 if ( ! function_exists( 'WC' ) ) { 73 80 add_action( 'admin_notices', 'woo_order_export_swatches_wc_notice' ); 74 81 } else { 75 82 require_once WOE_PLUGIN_DIR . 'includes/front-end/classes/class-woo-order-export.php'; 76 new Woo_Order_Export();77 83 } 78 84 } … … 81 87 /** 82 88 * Hook the plugin language translation file 89 90 83 91 * @since 1.0.0 84 * @return void.85 92 */ 86 93 if ( ! function_exists( 'woo_order_export_language' ) ) { 87 function woo_order_export_language() { 94 function woo_order_export_language () 95 { 88 96 load_plugin_textdomain( 'woo-order-export', false, WOE_PLUGIN_DIR . 'language' ); 89 97 } … … 92 100 /** 93 101 * Create the plugin download files directory in the upload directory 102 103 94 104 * @since 1.0.0 95 * @return void.96 105 */ 97 106 if ( ! function_exists( 'create_dir' ) ) { 98 function create_dir() { 107 function create_dir () 108 { 99 109 $dir_check = wp_get_upload_dir()[ 'basedir' ] . '/woo-roder-export'; 100 110 if ( ! is_dir( $dir_check ) ) { -
woo-order-export/trunk/readme.txt
r2171144 r2745695 1 1 === Woo Order Export === 2 2 Plugin Name: Woo Order Export 3 Plugin URI: https:// demo.themecat.org/woo-order-export4 Description: Woo Order Export isused to export the WooCommerce orders with all details. It has the option to export the order from a selectable date range and order status base.5 Version: 2.0 6 Author: Themecat_Info7 Author URI: https:// themecat.org/3 Plugin URI: https:// 4 Description: Woo Order Export used to export the WooCommerce orders with all details. It has the option to export the order from a selectable date range and order status base. 5 Version: 2.0 6 Author: 7 Author URI: https://.org/ 8 8 Text Domain: woo-order-export 9 9 Requires at least: 4.5 10 Tested up to: 5.210 Tested up to: 11 11 License: GPLv2 or later 12 12 License URI: https://www.gnu.org/licenses/gpl-2.0.html 13 13 Domain Path: /languages/ 14 14 WC requires at least: 3.0.0 15 WC tested up to: 3.615 WC tested up to: 16 16 17 An extension of WooCommerce that make products order downloadab elfriendly to customers.17 An extension of WooCommerce that make products order downloadab friendly to customers. 18 18 19 19 == Description ==
Note: See TracChangeset
for help on using the changeset viewer.