WooCommerce Sequential Order Numbers - Version 1.5.0

Version Description

  • 2015.07.28 =
  • Misc - WooCommerce 2.4 Compatibility
Download this release

Release Info

Developer SkyVerge
Plugin Icon WooCommerce Sequential Order Numbers
Version 1.5.0
Comparing to
See all releases

Code changes from version 1.4.0 to 1.5.0

i18n/languages/woocommerce-sequential-order-numbers.pot CHANGED
@@ -2,7 +2,7 @@
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WooCommerce Sequential Order Numbers 1.4.0\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://github.com/skyverge/woocommerce-sequential-order-numbers/issues\n"
8
  "POT-Creation-Date: 2014-09-05 22:27:38+00:00\n"
@@ -13,15 +13,13 @@ msgstr ""
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
- #: build/woocommerce-sequential-order-numbers.php:529
17
- #: woocommerce-sequential-order-numbers.php:540
18
  msgid ""
19
  "Error activating and installing <strong>WooCommerce Sequential Order "
20
  "Numbers</strong>: %s"
21
  msgstr ""
22
 
23
- #: build/woocommerce-sequential-order-numbers.php:530
24
- #: woocommerce-sequential-order-numbers.php:541
25
  msgid "&laquo; Go Back"
26
  msgstr ""
27
 
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce Sequential Order Numbers 1.5.0\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://github.com/skyverge/woocommerce-sequential-order-numbers/issues\n"
8
  "POT-Creation-Date: 2014-09-05 22:27:38+00:00\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
+ #: woocommerce-sequential-order-numbers.php:415
 
17
  msgid ""
18
  "Error activating and installing <strong>WooCommerce Sequential Order "
19
  "Numbers</strong>: %s"
20
  msgstr ""
21
 
22
+ #: woocommerce-sequential-order-numbers.php:416
 
23
  msgid "&laquo; Go Back"
24
  msgstr ""
25
 
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === WooCommerce Sequential Order Numbers ===
2
- Contributors: maxrice, tamarazuk, SkyVerge
3
  Tags: woocommerce, order number
4
  Requires at least: 3.8
5
- Tested up to: 4.1
6
- Requires WooCommerce at least: 2.1
7
- Tested WooCommerce up to: 2.3
8
- Stable tag: 1.4.0
9
 
10
  This plugin extends WooCommerce by setting sequential order numbers for new orders.
11
 
@@ -54,6 +54,9 @@ This free version does not have that functionality, but it's included in the pre
54
 
55
  == Changelog ==
56
 
 
 
 
57
  = 1.4.0 - 2015.02.10 =
58
  * Fix - Improved install routine for shops with a large number of orders
59
  * Misc - WooCommerce 2.3 compatibility
1
  === WooCommerce Sequential Order Numbers ===
2
+ Contributors: SkyVerge, maxrice, tamarazuk, chasewiseman, nekojira
3
  Tags: woocommerce, order number
4
  Requires at least: 3.8
5
+ Tested up to: 4.4
6
+ Requires WooCommerce at least: 2.2
7
+ Tested WooCommerce up to: 2.4.10
8
+ Stable tag: 1.5.0
9
 
10
  This plugin extends WooCommerce by setting sequential order numbers for new orders.
11
 
54
 
55
  == Changelog ==
56
 
57
+ = 1.5.0 - 2015.07.28 =
58
+ * Misc - WooCommerce 2.4 Compatibility
59
+
60
  = 1.4.0 - 2015.02.10 =
61
  * Fix - Improved install routine for shops with a large number of orders
62
  * Misc - WooCommerce 2.3 compatibility
woocommerce-sequential-order-numbers.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Provides sequential order numbers for WooCommerce orders
6
  * Author: SkyVerge
7
  * Author URI: http://www.skyverge.com
8
- * Version: 1.4.0
9
  * Text Domain: woocommerce-sequential-order-numbers
10
  * Domain Path: /i18n/languages/
11
  *
@@ -38,13 +38,13 @@ $GLOBALS['wc_seq_order_number'] = new WC_Seq_Order_Number();
38
  class WC_Seq_Order_Number {
39
 
40
  /** version number */
41
- const VERSION = "1.4.0";
42
 
43
  /** version option name */
44
  const VERSION_OPTION_NAME = "woocommerce_seq_order_number_db_version";
45
 
46
  /** minimum required wc version */
47
- const MINIMUM_WC_VERSION = '2.1';
48
 
49
 
50
  /**
@@ -130,7 +130,7 @@ class WC_Seq_Order_Number {
130
  'meta_key' => '_order_number',
131
  'meta_value' => $order_number,
132
  'post_type' => 'shop_order',
133
- 'post_status' => self::is_wc_version_gte_2_2() ? 'any' : 'publish',
134
  'fields' => 'ids',
135
  );
136
 
@@ -143,7 +143,12 @@ class WC_Seq_Order_Number {
143
  }
144
 
145
  // if we didn't find the order, then it may be that this plugin was disabled and an order was placed in the interim
146
- $order = self::wc_get_order( $order_number );
 
 
 
 
 
147
  if ( $order->order_number ) {
148
  // _order_number was set, so this is not an old order, it's a new one that just happened to have post_id that matched the searched-for order_number
149
  return 0;
@@ -322,125 +327,6 @@ class WC_Seq_Order_Number {
322
  /** Compatibility Methods ******************************************************/
323
 
324
 
325
- /**
326
- * Get the WC Order instance for a given order ID or order post
327
- *
328
- * Introduced in WC 2.2 as part of the Order Factory so the 2.1 version is
329
- * not an exact replacement.
330
- *
331
- * If no param is passed, it will use the global post. Otherwise pass an
332
- * the order post ID or post object.
333
- *
334
- * @since 1.3.2
335
- * @param bool|int|string|\WP_Post $the_order
336
- * @return bool|\WC_Order
337
- */
338
- public static function wc_get_order( $the_order = false ) {
339
-
340
- if ( self::is_wc_version_gte_2_2() ) {
341
-
342
- return wc_get_order( $the_order );
343
-
344
- } else {
345
-
346
- global $post;
347
-
348
- if ( false === $the_order ) {
349
-
350
- $order_id = $post->ID;
351
-
352
- } elseif ( $the_order instanceof WP_Post ) {
353
-
354
- $order_id = $the_order->ID;
355
-
356
- } elseif ( is_numeric( $the_order ) ) {
357
-
358
- $order_id = $the_order;
359
- }
360
-
361
- return new WC_Order( $order_id );
362
- }
363
- }
364
-
365
-
366
- /**
367
- * Transparently backport the `post_status` WP Query arg used by WC 2.2
368
- * for order statuses to the `shop_order_status` taxonomy query arg used by
369
- * WC 2.1
370
- *
371
- * @since 1.3.2
372
- * @param array $args WP_Query args
373
- * @return array
374
- */
375
- public static function backport_order_status_query_args( $args ) {
376
-
377
- if ( ! self::is_wc_version_gte_2_2() ) {
378
-
379
- // convert post status arg to taxonomy query compatible with WC 2.1
380
- if ( ! empty( $args['post_status'] ) ) {
381
-
382
- $order_statuses = array();
383
-
384
- foreach ( (array) $args['post_status'] as $order_status ) {
385
-
386
- $order_statuses[] = str_replace( 'wc-', '', $order_status );
387
- }
388
-
389
- $args['post_status'] = 'publish';
390
-
391
- $tax_query = array(
392
- array(
393
- 'taxonomy' => 'shop_order_status',
394
- 'field' => 'slug',
395
- 'terms' => $order_statuses,
396
- 'operator' => 'IN',
397
- )
398
- );
399
-
400
- $args['tax_query'] = array_merge( ( isset( $args['tax_query'] ) ? $args['tax_query'] : array() ), $tax_query );
401
- }
402
- }
403
-
404
- return $args;
405
- }
406
-
407
-
408
- /**
409
- * Get all order statuses
410
- *
411
- * Introduced in WC 2.2
412
- *
413
- * @since 1.3.4
414
- * @return array
415
- */
416
- public static function wc_get_order_statuses() {
417
-
418
- if ( self::is_wc_version_gte_2_2() ) {
419
-
420
- return wc_get_order_statuses();
421
-
422
- } else {
423
-
424
- // get available order statuses
425
- $order_status_terms = get_terms( 'shop_order_status', array( 'hide_empty' => false ) );
426
-
427
- if ( is_wp_error( $order_status_terms ) ) {
428
-
429
- $order_status_terms = array();
430
- }
431
-
432
- $order_statuses = array();
433
-
434
- foreach ( $order_status_terms as $term ) {
435
-
436
- $order_statuses[ $term->slug ] = $term->name;
437
- }
438
-
439
- return $order_statuses;
440
- }
441
- }
442
-
443
-
444
  /**
445
  * Helper method to get the version of the currently installed WooCommerce
446
  *
@@ -453,17 +339,6 @@ class WC_Seq_Order_Number {
453
  }
454
 
455
 
456
- /**
457
- * Returns true if the installed version of WooCommerce is 2.2 or greater
458
- *
459
- * @since 1.3.2
460
- * @return boolean true if the installed version of WooCommerce is 2.2 or greater
461
- */
462
- public static function is_wc_version_gte_2_2() {
463
- return self::get_wc_version() && version_compare( self::get_wc_version(), '2.2', '>=' );
464
- }
465
-
466
-
467
  /**
468
  * Returns true if the installed version of WooCommerce is 2.3 or greater
469
  *
@@ -530,7 +405,7 @@ class WC_Seq_Order_Number {
530
  do {
531
 
532
  // initial install, set the order number for all existing orders to the post id
533
- $order_ids = get_posts( array( 'post_type' => 'shop_order', 'fields' => 'ids', 'offset' => $offset, 'posts_per_page' => $posts_per_page, 'post_status' => self::is_wc_version_gte_2_2() ? 'any' : 'publish' ) );
534
 
535
  // some sort of bad database error: deactivate the plugin and display an error
536
  if ( is_wp_error( $order_ids ) ) {
5
  * Description: Provides sequential order numbers for WooCommerce orders
6
  * Author: SkyVerge
7
  * Author URI: http://www.skyverge.com
8
+ * Version: 1.5.0
9
  * Text Domain: woocommerce-sequential-order-numbers
10
  * Domain Path: /i18n/languages/
11
  *
38
  class WC_Seq_Order_Number {
39
 
40
  /** version number */
41
+ const VERSION = "1.5.0";
42
 
43
  /** version option name */
44
  const VERSION_OPTION_NAME = "woocommerce_seq_order_number_db_version";
45
 
46
  /** minimum required wc version */
47
+ const MINIMUM_WC_VERSION = '2.2';
48
 
49
 
50
  /**
130
  'meta_key' => '_order_number',
131
  'meta_value' => $order_number,
132
  'post_type' => 'shop_order',
133
+ 'post_status' => 'any',
134
  'fields' => 'ids',
135
  );
136
 
143
  }
144
 
145
  // if we didn't find the order, then it may be that this plugin was disabled and an order was placed in the interim
146
+ $order = wc_get_order( $order_number );
147
+
148
+ if ( ! $order ) {
149
+ return 0;
150
+ }
151
+
152
  if ( $order->order_number ) {
153
  // _order_number was set, so this is not an old order, it's a new one that just happened to have post_id that matched the searched-for order_number
154
  return 0;
327
  /** Compatibility Methods ******************************************************/
328
 
329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  /**
331
  * Helper method to get the version of the currently installed WooCommerce
332
  *
339
  }
340
 
341
 
 
 
 
 
 
 
 
 
 
 
 
342
  /**
343
  * Returns true if the installed version of WooCommerce is 2.3 or greater
344
  *
405
  do {
406
 
407
  // initial install, set the order number for all existing orders to the post id
408
+ $order_ids = get_posts( array( 'post_type' => 'shop_order', 'fields' => 'ids', 'offset' => $offset, 'posts_per_page' => $posts_per_page, 'post_status' => 'any' ) );
409
 
410
  // some sort of bad database error: deactivate the plugin and display an error
411
  if ( is_wp_error( $order_ids ) ) {