WooCommerce Sequential Order Numbers - Version 1.5.1

Version Description

  • 2015.11.26 =
  • Fix - Compatibility fix with WooCommerce Subscriptions 2.0
Download this release

Release Info

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

Code changes from version 1.5.0 to 1.5.1

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.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,13 +13,13 @@ msgstr ""
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
 
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.1\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:444
17
  msgid ""
18
  "Error activating and installing <strong>WooCommerce Sequential Order "
19
  "Numbers</strong>: %s"
20
  msgstr ""
21
 
22
+ #: woocommerce-sequential-order-numbers.php:445
23
  msgid "&laquo; Go Back"
24
  msgstr ""
25
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ 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,6 +54,9 @@ This free version does not have that functionality, but it's included in the pre
54
 
55
  == Changelog ==
56
 
 
 
 
57
  = 1.5.0 - 2015.07.28 =
58
  * Misc - WooCommerce 2.4 Compatibility
59
 
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.1
9
 
10
  This plugin extends WooCommerce by setting sequential order numbers for new orders.
11
 
54
 
55
  == Changelog ==
56
 
57
+ = 1.5.1 - 2015.11.26 =
58
+ * Fix - Compatibility fix with WooCommerce Subscriptions 2.0
59
+
60
  = 1.5.0 - 2015.07.28 =
61
  * Misc - WooCommerce 2.4 Compatibility
62
 
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.5.0
9
  * Text Domain: woocommerce-sequential-order-numbers
10
  * Domain Path: /i18n/languages/
11
  *
@@ -38,7 +38,7 @@ $GLOBALS['wc_seq_order_number'] = new WC_Seq_Order_Number();
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";
@@ -85,7 +85,12 @@ class WC_Seq_Order_Number {
85
 
86
  // WC Subscriptions support: prevent unnecessary order meta from polluting parent renewal orders, and set order number for subscription orders
87
  add_filter( 'woocommerce_subscriptions_renewal_order_meta_query', array( $this, 'subscriptions_remove_renewal_order_meta' ), 10, 4 );
88
- add_action( 'woocommerce_subscriptions_renewal_order_created', array( $this, 'subscriptions_set_sequential_order_number' ), 10, 4 );
 
 
 
 
 
89
 
90
  if ( is_admin() ) {
91
  add_filter( 'request', array( $this, 'woocommerce_custom_shop_order_orderby' ), 20 );
@@ -119,7 +124,6 @@ class WC_Seq_Order_Number {
119
  * Search for an order with order_number $order_number
120
  *
121
  * @param string $order_number order number to search for
122
- *
123
  * @return int post_id for the order identified by $order_number, or 0
124
  */
125
  public function find_order_by_order_number( $order_number ) {
@@ -195,7 +199,6 @@ class WC_Seq_Order_Number {
195
  *
196
  * @param string $order_number the order id with a leading hash
197
  * @param WC_Order $order the order object
198
- *
199
  * @return string custom order number, with leading hash for < WC 2.3
200
  */
201
  public function get_order_number( $order_number, $order ) {
@@ -215,7 +218,6 @@ class WC_Seq_Order_Number {
215
  * Admin order table orderby ID operates on our meta _order_number
216
  *
217
  * @param array $vars associative array of orderby parameteres
218
- *
219
  * @return array associative array of orderby parameteres
220
  */
221
  public function woocommerce_custom_shop_order_orderby( $vars ) {
@@ -233,7 +235,7 @@ class WC_Seq_Order_Number {
233
  * Mofifies the given $args argument to sort on our meta integral _order_number
234
  *
235
  * @since 1.3
236
- * @param array $vars associative array of orderby parameteres
237
  * @return array associative array of orderby parameteres
238
  */
239
  public function custom_orderby( $args ) {
@@ -254,7 +256,6 @@ class WC_Seq_Order_Number {
254
  * the admin search functionality is maintained
255
  *
256
  * @param array $search_fields array of post meta fields to search by
257
- *
258
  * @return array of post meta fields to search by
259
  */
260
  public function custom_search_fields( $search_fields ) {
@@ -268,19 +269,48 @@ class WC_Seq_Order_Number {
268
  /** 3rd Party Plugin Support ******************************************************/
269
 
270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  /**
272
  * Sets an order number on a subscriptions-created order
273
  *
274
  * @since 1.3
275
- *
276
  * @param WC_Order $renewal_order the new renewal order object
277
  * @param WC_Order $original_order the original order object
278
  * @param int $product_id the product post identifier
279
  * @param string $new_order_role the role the renewal order is taking, one of 'parent' or 'child'
 
280
  */
281
  public function subscriptions_set_sequential_order_number( $renewal_order, $original_order, $product_id, $new_order_role ) {
 
282
  $order_post = get_post( $renewal_order->id );
283
  $this->set_sequential_order_number( $order_post->ID, $order_post );
 
 
 
 
284
  }
285
 
286
 
@@ -288,7 +318,6 @@ class WC_Seq_Order_Number {
288
  * Don't copy over order number meta when creating a parent or child renewal order
289
  *
290
  * @since 1.3
291
- *
292
  * @param array $order_meta_query query for pulling the metadata
293
  * @param int $original_order_id Post ID of the order being used to purchased the subscription being renewed
294
  * @param int $renewal_order_id Post ID of the order created for renewing the subscription
@@ -309,7 +338,7 @@ class WC_Seq_Order_Number {
309
  /**
310
  * Checks if WooCommerce is active
311
  *
312
- * @since 1.3
313
  * @return bool true if WooCommerce is active, false otherwise
314
  */
315
  public static function is_woocommerce_active() {
5
  * Description: Provides sequential order numbers for WooCommerce orders
6
  * Author: SkyVerge
7
  * Author URI: http://www.skyverge.com
8
+ * Version: 1.5.1
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.1";
42
 
43
  /** version option name */
44
  const VERSION_OPTION_NAME = "woocommerce_seq_order_number_db_version";
85
 
86
  // WC Subscriptions support: prevent unnecessary order meta from polluting parent renewal orders, and set order number for subscription orders
87
  add_filter( 'woocommerce_subscriptions_renewal_order_meta_query', array( $this, 'subscriptions_remove_renewal_order_meta' ), 10, 4 );
88
+
89
+ if ( self::is_wc_subscriptions_version_gte_2_0() ) {
90
+ add_filter( 'woocommerce_subscriptions_renewal_order_created', array( $this, 'subscriptions_set_sequential_order_number' ), 10, 4 );
91
+ } else {
92
+ add_action( 'woocommerce_subscriptions_renewal_order_created', array( $this, 'subscriptions_set_sequential_order_number' ), 10, 4 );
93
+ }
94
 
95
  if ( is_admin() ) {
96
  add_filter( 'request', array( $this, 'woocommerce_custom_shop_order_orderby' ), 20 );
124
  * Search for an order with order_number $order_number
125
  *
126
  * @param string $order_number order number to search for
 
127
  * @return int post_id for the order identified by $order_number, or 0
128
  */
129
  public function find_order_by_order_number( $order_number ) {
199
  *
200
  * @param string $order_number the order id with a leading hash
201
  * @param WC_Order $order the order object
 
202
  * @return string custom order number, with leading hash for < WC 2.3
203
  */
204
  public function get_order_number( $order_number, $order ) {
218
  * Admin order table orderby ID operates on our meta _order_number
219
  *
220
  * @param array $vars associative array of orderby parameteres
 
221
  * @return array associative array of orderby parameteres
222
  */
223
  public function woocommerce_custom_shop_order_orderby( $vars ) {
235
  * Mofifies the given $args argument to sort on our meta integral _order_number
236
  *
237
  * @since 1.3
238
+ * @param array $args associative array of orderby parameteres
239
  * @return array associative array of orderby parameteres
240
  */
241
  public function custom_orderby( $args ) {
256
  * the admin search functionality is maintained
257
  *
258
  * @param array $search_fields array of post meta fields to search by
 
259
  * @return array of post meta fields to search by
260
  */
261
  public function custom_search_fields( $search_fields ) {
269
  /** 3rd Party Plugin Support ******************************************************/
270
 
271
 
272
+ /**
273
+ * Helper method to get the version of WooCommerce Subscriptions
274
+ *
275
+ * @since 1.5.1
276
+ * @return string|null WC_Subscriptions version number or null if not found
277
+ */
278
+ protected static function get_wc_subscriptions_version() {
279
+
280
+ return class_exists( 'WC_Subscriptions' ) && ! empty( WC_Subscriptions::$version ) ? WC_Subscriptions::$version : null;
281
+ }
282
+
283
+
284
+ /**
285
+ * Returns true if the installed version of WooCommerce Subscriptions is 2.0.0 or greater
286
+ *
287
+ * @since 1.5.1
288
+ * @return boolean
289
+ */
290
+ protected static function is_wc_subscriptions_version_gte_2_0() {
291
+
292
+ return self::get_wc_subscriptions_version() && version_compare( self::get_wc_subscriptions_version(), '2.0-beta-1', '>=' );
293
+ }
294
+
295
+
296
  /**
297
  * Sets an order number on a subscriptions-created order
298
  *
299
  * @since 1.3
 
300
  * @param WC_Order $renewal_order the new renewal order object
301
  * @param WC_Order $original_order the original order object
302
  * @param int $product_id the product post identifier
303
  * @param string $new_order_role the role the renewal order is taking, one of 'parent' or 'child'
304
+ * @return void|WC_Order Renewal order instance for Subscriptions 2.0+
305
  */
306
  public function subscriptions_set_sequential_order_number( $renewal_order, $original_order, $product_id, $new_order_role ) {
307
+
308
  $order_post = get_post( $renewal_order->id );
309
  $this->set_sequential_order_number( $order_post->ID, $order_post );
310
+
311
+ if ( self::is_wc_subscriptions_version_gte_2_0() ) {
312
+ return $renewal_order;
313
+ }
314
  }
315
 
316
 
318
  * Don't copy over order number meta when creating a parent or child renewal order
319
  *
320
  * @since 1.3
 
321
  * @param array $order_meta_query query for pulling the metadata
322
  * @param int $original_order_id Post ID of the order being used to purchased the subscription being renewed
323
  * @param int $renewal_order_id Post ID of the order created for renewing the subscription
338
  /**
339
  * Checks if WooCommerce is active
340
  *
341
+ * @since 1.3
342
  * @return bool true if WooCommerce is active, false otherwise
343
  */
344
  public static function is_woocommerce_active() {