WooCommerce Sequential Order Numbers - Version 1.4.0

Version Description

  • 2015.02.10 =
  • Fix - Improved install routine for shops with a large number of orders
  • Misc - WooCommerce 2.3 compatibility
Download this release

Release Info

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

Code changes from version 1.3.4 to 1.4.0

i18n/languages/woocommerce-sequential-order-numbers.pot CHANGED
@@ -1,18 +1,30 @@
1
- # Copyright (C) 2014 SkyVerge
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.3.4\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"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  #. Plugin Name of the plugin/theme
17
  msgid "WooCommerce Sequential Order Numbers"
18
  msgstr ""
1
+ # Copyright (C) 2015 SkyVerge
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"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
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
+
28
  #. Plugin Name of the plugin/theme
29
  msgid "WooCommerce Sequential Order Numbers"
30
  msgstr ""
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === WooCommerce Sequential Order Numbers ===
2
- Contributors: maxrice, justinstern, tamarazuk, SkyVerge
3
  Tags: woocommerce, order number
4
  Requires at least: 3.8
5
- Tested up to: 4.0
6
- Requires WooCommerce at least: 2.0
7
- Tested WooCommerce up to: 2.2
8
- Stable tag: 1.3.4
9
 
10
  This plugin extends WooCommerce by setting sequential order numbers for new orders.
11
 
@@ -13,25 +13,30 @@ This plugin extends WooCommerce by setting sequential order numbers for new orde
13
 
14
  This plugin extends WooCommerce by automatically setting sequential order numbers for new orders. If there are existing orders at the time of installation, the sequential order numbers will start with the highest current order number.
15
 
16
- > No configuration needed! The plugin is so easy to use, there aren't even any settings. Activate it, and orders will automatically become sequential.
17
 
18
- If you like this plugin, but are looking for the ability to set the starting number, or to add a custom prefix/suffix to your order numbers (ie, you'd prefer something like WT101UK, WT102UK, etc) please consider our premium WooCommerce Sequential Order Numbers Pro plugin, available from the [WooThemes Store](http://www.woothemes.com/products/sequential-order-numbers-pro/)
19
 
20
- This plugin requires WooCommerce 2.1 or greater.
21
 
22
  = Feedback =
23
  * We are open to your suggestions and feedback - Thank you for using or trying out one of our plugins!
24
  * Drop us a line at [www.skyverge.com](http://www.skyverge.com)
25
 
26
- = More =
27
- * Vist the [WooCommerce Sequential Order Number plugin page](http://www.skyverge.com/blog/woocommerce-sequential-order-numbers/) for further details and a discussion of the implementation. [Also see our other plugins](http://www.skyverge.com) or see [our WordPress.org profile page](http://profiles.wordpress.org/skyverge/)
28
- * Find the enhanced WooCommerce Sequential Order Numbers Pro now available from [WooThemes](http://www.woothemes.com/products/sequential-order-numbers-pro/)
 
 
 
 
 
29
 
30
  == Installation ==
31
 
32
- 1. Upload the entire 'woocommerce-sequential-order-numbers' folder to the '/wp-content/plugins/' directory
33
  2. Activate the plugin through the 'Plugins' menu in WordPress
34
- 3. Order numbers will continue sequentially from the current highest order number, or from 1 if no orders have been placed yet
35
 
36
  == Frequently Asked Questions ==
37
 
@@ -41,14 +46,18 @@ The plugin doesn't require any :). When you activate it, it gets to work right a
41
 
42
  = Can I start the order numbers at a particular number? =
43
 
44
- This free version does not have that functionality, but now you can with the premium [WooCommerce Sequential Order Numbers Pro](http://www.woothemes.com/products/sequential-order-numbers-pro/)
45
 
46
  = Can I set an order number prefix/suffix? =
47
 
48
- This free version does not have that functionality, but now you can with the premium [WooCommerce Sequential Order Numbers Pro](http://www.woothemes.com/products/sequential-order-numbers-pro/)
49
 
50
  == Changelog ==
51
 
 
 
 
 
52
  = 1.3.4 - 2014.09.23 =
53
  * Fix - Compatibility fix with WooCommerce 2.1
54
  * Fix - Fix a deprecated notice in WooCommerce 2.2
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
 
13
 
14
  This plugin extends WooCommerce by automatically setting sequential order numbers for new orders. If there are existing orders at the time of installation, the sequential order numbers will start with the highest current order number.
15
 
16
+ **This plugin requires WooCommerce 2.1 or newer.**
17
 
18
+ > No configuration needed! The plugin is so easy to use, there aren't even any settings. Activate it, and orders will automatically become sequential.
19
 
20
+ If you like this plugin, but are looking for the ability to set the starting number, or to add a custom prefix/suffix to your order numbers (ie, you'd prefer something like WT101UK, WT102UK, etc) please consider our premium WooCommerce Sequential Order Numbers Pro plugin, which is available in the [WooThemes Store](http://www.woothemes.com/products/sequential-order-numbers-pro/).
21
 
22
  = Feedback =
23
  * We are open to your suggestions and feedback - Thank you for using or trying out one of our plugins!
24
  * Drop us a line at [www.skyverge.com](http://www.skyverge.com)
25
 
26
+ = Support Details =
27
+ We do support our free plugins and extensions, but please understand that support for premium products takes priority. We typically check the forums every few days (with a maximum delay of one week).
28
+
29
+ = More Details =
30
+ - See the [product page](http://www.skyverge.com/product/woocommerce-sequential-order-numbers/) for full details.
31
+ - Check out the [Pro Version](http://www.woothemes.com/products/sequential-order-numbers-pro/).
32
+ - View more of SkyVerge's [free WooCommerce extensions](http://profiles.wordpress.org/skyverge/)
33
+ - View all [SkyVerge WooCommerce extensions](http://www.skyverge.com/shop/)
34
 
35
  == Installation ==
36
 
37
+ 1. Upload the entire 'woocommerce-sequential-order-numbers' folder to the '/wp-content/plugins/' directory or upload the zip via Plugins &gt; Add New
38
  2. Activate the plugin through the 'Plugins' menu in WordPress
39
+ 3. No configuration needed! Order numbers will continue sequentially from the current highest order number, or from 1 if no orders have been placed yet
40
 
41
  == Frequently Asked Questions ==
42
 
46
 
47
  = Can I start the order numbers at a particular number? =
48
 
49
+ This free version does not have that functionality, but the premium [WooCommerce Sequential Order Numbers Pro](http://www.woothemes.com/products/sequential-order-numbers-pro/) will allow you to choose any starting number that's higher than your most current order number.
50
 
51
  = Can I set an order number prefix/suffix? =
52
 
53
+ This free version does not have that functionality, but it's included in the premium [WooCommerce Sequential Order Numbers Pro](http://www.woothemes.com/products/sequential-order-numbers-pro/).
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
60
+
61
  = 1.3.4 - 2014.09.23 =
62
  * Fix - Compatibility fix with WooCommerce 2.1
63
  * Fix - Fix a deprecated notice in WooCommerce 2.2
woocommerce-sequential-order-numbers.php CHANGED
@@ -5,7 +5,9 @@
5
  * Description: Provides sequential order numbers for WooCommerce orders
6
  * Author: SkyVerge
7
  * Author URI: http://www.skyverge.com
8
- * Version: 1.3.4
 
 
9
  *
10
  * Copyright: (c) 2012-2013 SkyVerge, Inc. (info@skyverge.com)
11
  *
@@ -36,7 +38,7 @@ $GLOBALS['wc_seq_order_number'] = new WC_Seq_Order_Number();
36
  class WC_Seq_Order_Number {
37
 
38
  /** version number */
39
- const VERSION = "1.3.4";
40
 
41
  /** version option name */
42
  const VERSION_OPTION_NAME = "woocommerce_seq_order_number_db_version";
@@ -189,12 +191,12 @@ class WC_Seq_Order_Number {
189
  * @param string $order_number the order id with a leading hash
190
  * @param WC_Order $order the order object
191
  *
192
- * @return string custom order number, with leading hash
193
  */
194
  public function get_order_number( $order_number, $order ) {
195
 
196
  if ( $order->order_number ) {
197
- return '#' . $order->order_number;
198
  }
199
 
200
  return $order_number;
@@ -462,6 +464,17 @@ class WC_Seq_Order_Number {
462
  }
463
 
464
 
 
 
 
 
 
 
 
 
 
 
 
465
  /**
466
  * Perform a minimum WooCommerce version check
467
  *
@@ -508,15 +521,41 @@ class WC_Seq_Order_Number {
508
  $installed_version = get_option( WC_Seq_Order_Number::VERSION_OPTION_NAME );
509
 
510
  if ( ! $installed_version ) {
511
- // initial install, set the order number for all existing orders to the post id
512
- $orders = get_posts( array( 'numberposts' => '', 'post_type' => 'shop_order', 'nopaging' => true, 'post_status' => self::is_wc_version_gte_2_2() ? 'any' : 'publish' ) );
513
- if ( is_array( $orders ) ) {
514
- foreach( $orders as $order ) {
515
- if ( '' == get_post_meta( $order->ID, '_order_number', true ) ) {
516
- add_post_meta( $order->ID, '_order_number', $order->ID );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
517
  }
518
  }
519
- }
 
 
 
 
 
 
520
  }
521
 
522
  if ( $installed_version != WC_Seq_Order_Number::VERSION ) {
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
  *
12
  * Copyright: (c) 2012-2013 SkyVerge, Inc. (info@skyverge.com)
13
  *
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";
191
  * @param string $order_number the order id with a leading hash
192
  * @param WC_Order $order the order object
193
  *
194
+ * @return string custom order number, with leading hash for < WC 2.3
195
  */
196
  public function get_order_number( $order_number, $order ) {
197
 
198
  if ( $order->order_number ) {
199
+ return ( self::is_wc_version_gte_2_3() ? '' : '#' ) . $order->order_number;
200
  }
201
 
202
  return $order_number;
464
  }
465
 
466
 
467
+ /**
468
+ * Returns true if the installed version of WooCommerce is 2.3 or greater
469
+ *
470
+ * @since 1.4.0
471
+ * @return boolean true if the installed version of WooCommerce is 2.3 or greater
472
+ */
473
+ public static function is_wc_version_gte_2_3() {
474
+ return self::get_wc_version() && version_compare( self::get_wc_version(), '2.3', '>=' );
475
+ }
476
+
477
+
478
  /**
479
  * Perform a minimum WooCommerce version check
480
  *
521
  $installed_version = get_option( WC_Seq_Order_Number::VERSION_OPTION_NAME );
522
 
523
  if ( ! $installed_version ) {
524
+
525
+ // initial install, set the order number for all existing orders to the post id:
526
+ // page through the "publish" orders in blocks to avoid out of memory errors
527
+ $offset = (int) get_option( 'wc_sequential_order_numbers_install_offset', 0 );
528
+ $posts_per_page = 500;
529
+
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 ) ) {
537
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
538
+ deactivate_plugins( 'woocommerce-sequential-order-numbers/woocommerce-sequential-order-numbers.php' ); // hardcode the plugin path so that we can use symlinks in development
539
+
540
+ wp_die( sprintf( __( 'Error activating and installing <strong>WooCommerce Sequential Order Numbers</strong>: %s', 'woocommerce-sequential-order-numbers' ), '<ul><li>' . implode( '</li><li>', $order_ids->get_error_messages() ) . '</li></ul>' ) .
541
+ '<a href="' . admin_url( 'plugins.php' ) . '">' . __( '&laquo; Go Back', 'woocommerce-sequential-order-numbers' ) . '</a>' );
542
+ }
543
+
544
+
545
+ if ( is_array( $order_ids ) ) {
546
+ foreach( $order_ids as $order_id ) {
547
+ if ( '' == get_post_meta( $order_id, '_order_number', true ) ) {
548
+ add_post_meta( $order_id, '_order_number', $order_id );
549
+ }
550
  }
551
  }
552
+
553
+ // increment offset
554
+ $offset += $posts_per_page;
555
+ // and keep track of how far we made it in case we hit a script timeout
556
+ update_option( 'wc_sequential_order_numbers_install_offset', $offset );
557
+
558
+ } while ( count( $order_ids ) == $posts_per_page ); // while full set of results returned (meaning there may be more results still to retrieve)
559
  }
560
 
561
  if ( $installed_version != WC_Seq_Order_Number::VERSION ) {