Version Description
- 2017.03.23 =
- Fix - Admin orderby was not properly scoped to orders, props @brandondove
- Misc - Added support for WooCommerce 3.0
- Misc - Removed support for WooCommerce 2.4
Download this release
Release Info
Developer | SkyVerge |
Plugin | WooCommerce Sequential Order Numbers |
Version | 1.8.0 |
Comparing to | |
See all releases |
Code changes from version 1.7.0 to 1.8.0
i18n/languages/woocommerce-sequential-order-numbers.pot
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
# Copyright (C)
|
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.
|
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:
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
|
@@ -23,14 +23,14 @@ msgstr ""
|
|
23 |
msgid "You cannot unserialize instances of %s."
|
24 |
msgstr ""
|
25 |
|
26 |
-
#: woocommerce-sequential-order-numbers.php:
|
27 |
#. Translators: %s - error message(s)
|
28 |
msgid ""
|
29 |
"Error activating and installing <strong>WooCommerce Sequential Order "
|
30 |
"Numbers</strong>: %s"
|
31 |
msgstr ""
|
32 |
|
33 |
-
#: woocommerce-sequential-order-numbers.php:
|
34 |
msgid "« Go Back"
|
35 |
msgstr ""
|
36 |
|
1 |
+
# Copyright (C) 2017 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.8.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: 2017-MO-DA HO:MI+ZONE\n"
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
|
23 |
msgid "You cannot unserialize instances of %s."
|
24 |
msgstr ""
|
25 |
|
26 |
+
#: woocommerce-sequential-order-numbers.php:551
|
27 |
#. Translators: %s - error message(s)
|
28 |
msgid ""
|
29 |
"Error activating and installing <strong>WooCommerce Sequential Order "
|
30 |
"Numbers</strong>: %s"
|
31 |
msgstr ""
|
32 |
|
33 |
+
#: woocommerce-sequential-order-numbers.php:552
|
34 |
msgid "« Go Back"
|
35 |
msgstr ""
|
36 |
|
readme.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
=== WooCommerce Sequential Order Numbers ===
|
2 |
-
Contributors: SkyVerge, maxrice, tamarazuk, chasewiseman, nekojira
|
3 |
-
Tags: woocommerce, order number
|
4 |
Requires at least: 4.1
|
5 |
-
Tested up to: 4.
|
6 |
-
Requires WooCommerce at least: 2.
|
7 |
-
Tested WooCommerce up to:
|
8 |
-
Stable tag: 1.
|
9 |
|
10 |
This plugin extends WooCommerce by setting sequential order numbers for new orders.
|
11 |
|
@@ -13,7 +13,7 @@ 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 |
-
**This plugin requires WooCommerce 2.
|
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 |
|
@@ -27,11 +27,11 @@ We do support our free plugins and extensions, but please understand that suppor
|
|
27 |
|
28 |
= Sequential Order Numbers Pro =
|
29 |
|
30 |
-
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 [
|
31 |
|
32 |
= More Details =
|
33 |
- See the [product page](http://www.skyverge.com/product/woocommerce-sequential-order-numbers/) for full details.
|
34 |
-
- Check out the [Pro Version](http://
|
35 |
- View more of SkyVerge's [free WooCommerce extensions](http://profiles.wordpress.org/skyverge/)
|
36 |
- View all [SkyVerge WooCommerce extensions](http://www.skyverge.com/shop/)
|
37 |
|
@@ -103,6 +103,11 @@ $order_number = $order->get_order_number();
|
|
103 |
|
104 |
== Changelog ==
|
105 |
|
|
|
|
|
|
|
|
|
|
|
106 |
= 1.7.0 - 2016.05.24 =
|
107 |
* Misc - Added support for WooCommerce 2.6
|
108 |
* Misc - Removed support for WooCommerce 2.3
|
1 |
=== WooCommerce Sequential Order Numbers ===
|
2 |
+
Contributors: SkyVerge, maxrice, tamarazuk, chasewiseman, nekojira, beka.rice
|
3 |
+
Tags: woocommerce, order number, sequential order number, woocommerce orders
|
4 |
Requires at least: 4.1
|
5 |
+
Tested up to: 4.7.3
|
6 |
+
Requires WooCommerce at least: 2.5.5
|
7 |
+
Tested WooCommerce up to: 3.0
|
8 |
+
Stable tag: 1.8.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.5.5 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 |
|
27 |
|
28 |
= Sequential Order Numbers Pro =
|
29 |
|
30 |
+
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 [WooCommerce Store](http://woocommerce.com/products/sequential-order-numbers-pro/).
|
31 |
|
32 |
= More Details =
|
33 |
- See the [product page](http://www.skyverge.com/product/woocommerce-sequential-order-numbers/) for full details.
|
34 |
+
- Check out the [Pro Version](http://woocommerce.com/products/sequential-order-numbers-pro/).
|
35 |
- View more of SkyVerge's [free WooCommerce extensions](http://profiles.wordpress.org/skyverge/)
|
36 |
- View all [SkyVerge WooCommerce extensions](http://www.skyverge.com/shop/)
|
37 |
|
103 |
|
104 |
== Changelog ==
|
105 |
|
106 |
+
= 1.8.0 - 2017.03.23 =
|
107 |
+
* Fix - Admin orderby was not properly scoped to orders, props [@brandondove](https://github.com/brandondove)
|
108 |
+
* Misc - Added support for WooCommerce 3.0
|
109 |
+
* Misc - Removed support for WooCommerce 2.4
|
110 |
+
|
111 |
= 1.7.0 - 2016.05.24 =
|
112 |
* Misc - Added support for WooCommerce 2.6
|
113 |
* Misc - Removed support for WooCommerce 2.3
|
woocommerce-sequential-order-numbers.php
CHANGED
@@ -5,11 +5,11 @@
|
|
5 |
* Description: Provides sequential order numbers for WooCommerce orders
|
6 |
* Author: SkyVerge
|
7 |
* Author URI: http://www.skyverge.com
|
8 |
-
* Version: 1.
|
9 |
* Text Domain: woocommerce-sequential-order-numbers
|
10 |
* Domain Path: /i18n/languages/
|
11 |
*
|
12 |
-
* Copyright: (c) 2012-
|
13 |
*
|
14 |
* License: GNU General Public License v3.0
|
15 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
@@ -17,7 +17,7 @@
|
|
17 |
* @package WC-Sequential-Order-Numbers
|
18 |
* @author SkyVerge
|
19 |
* @category Plugin
|
20 |
-
* @copyright Copyright (c) 2012-
|
21 |
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
|
22 |
*/
|
23 |
|
@@ -32,7 +32,7 @@ class WC_Seq_Order_Number {
|
|
32 |
|
33 |
|
34 |
/** version number */
|
35 |
-
const VERSION = '1.
|
36 |
|
37 |
/** @var \WC_Seq_Order_Number single instance of this plugin */
|
38 |
protected static $instance;
|
@@ -41,7 +41,7 @@ class WC_Seq_Order_Number {
|
|
41 |
const VERSION_OPTION_NAME = 'woocommerce_seq_order_number_db_version';
|
42 |
|
43 |
/** minimum required wc version */
|
44 |
-
const MINIMUM_WC_VERSION = '2.
|
45 |
|
46 |
|
47 |
/**
|
@@ -174,12 +174,12 @@ class WC_Seq_Order_Number {
|
|
174 |
return 0;
|
175 |
}
|
176 |
|
177 |
-
if ( $order
|
178 |
// _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
|
179 |
return 0;
|
180 |
}
|
181 |
|
182 |
-
return $order
|
183 |
}
|
184 |
|
185 |
|
@@ -187,14 +187,15 @@ class WC_Seq_Order_Number {
|
|
187 |
* Set the _order_number field for the newly created order
|
188 |
*
|
189 |
* @param int $post_id post identifier
|
190 |
-
* @param WP_Post $post post object
|
191 |
*/
|
192 |
public function set_sequential_order_number( $post_id, $post ) {
|
193 |
global $wpdb;
|
194 |
|
195 |
if ( 'shop_order' === $post->post_type && 'auto-draft' !== $post->post_status ) {
|
196 |
|
197 |
-
$
|
|
|
198 |
|
199 |
if ( '' === $order_number ) {
|
200 |
|
@@ -203,6 +204,7 @@ class WC_Seq_Order_Number {
|
|
203 |
for ( $i = 0; $i < 3 && ! $success; $i++ ) {
|
204 |
|
205 |
// this seems to me like the safest way to avoid order number clashes
|
|
|
206 |
$query = $wpdb->prepare( "
|
207 |
INSERT INTO {$wpdb->postmeta} (post_id, meta_key, meta_value)
|
208 |
SELECT %d, '_order_number', IF( MAX( CAST( meta_value as UNSIGNED ) ) IS NULL, 1, MAX( CAST( meta_value as UNSIGNED ) ) + 1 )
|
@@ -227,8 +229,8 @@ class WC_Seq_Order_Number {
|
|
227 |
*/
|
228 |
public function get_order_number( $order_number, $order ) {
|
229 |
|
230 |
-
if ( $order
|
231 |
-
|
232 |
}
|
233 |
|
234 |
return $order_number;
|
@@ -245,9 +247,9 @@ class WC_Seq_Order_Number {
|
|
245 |
* @return array associative array of orderby parameteres
|
246 |
*/
|
247 |
public function woocommerce_custom_shop_order_orderby( $vars ) {
|
248 |
-
global $typenow
|
249 |
|
250 |
-
if ( 'shop_order'
|
251 |
return $vars;
|
252 |
}
|
253 |
|
@@ -309,6 +311,8 @@ class WC_Seq_Order_Number {
|
|
309 |
/**
|
310 |
* Returns true if the installed version of WooCommerce Subscriptions is 2.0.0 or greater
|
311 |
*
|
|
|
|
|
312 |
* @since 1.5.1
|
313 |
* @return boolean
|
314 |
*/
|
@@ -321,9 +325,9 @@ class WC_Seq_Order_Number {
|
|
321 |
* Sets an order number on a subscriptions-created order
|
322 |
*
|
323 |
* @since 1.3
|
324 |
-
* @param WC_Order $renewal_order the new renewal order object
|
325 |
-
* @param WC_Order $original_order the original order object (Subscriptions 2.0+: Subscription object)
|
326 |
-
* @return void
|
327 |
*/
|
328 |
public function subscriptions_set_sequential_order_number( $renewal_order, $original_order ) {
|
329 |
|
@@ -388,39 +392,90 @@ class WC_Seq_Order_Number {
|
|
388 |
}
|
389 |
|
390 |
|
391 |
-
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
|
393 |
|
394 |
/**
|
395 |
-
* Helper method to get
|
396 |
*
|
397 |
-
*
|
398 |
-
*
|
|
|
|
|
|
|
|
|
|
|
399 |
*/
|
400 |
-
|
401 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
}
|
403 |
|
404 |
|
|
|
|
|
|
|
405 |
/**
|
406 |
-
*
|
407 |
*
|
408 |
-
* @since 1.
|
409 |
-
* @return
|
410 |
*/
|
411 |
-
|
412 |
-
return
|
413 |
}
|
414 |
|
415 |
|
416 |
/**
|
417 |
-
* Returns true if the installed version of WooCommerce is
|
418 |
*
|
419 |
-
* @since 1.
|
420 |
-
* @return boolean true if the installed version of WooCommerce is
|
421 |
*/
|
422 |
-
|
423 |
-
return self::get_wc_version() && version_compare( self::get_wc_version(), '
|
424 |
}
|
425 |
|
426 |
|
@@ -468,8 +523,11 @@ class WC_Seq_Order_Number {
|
|
468 |
|
469 |
/**
|
470 |
* Run every time. Used since the activation hook is not executed when updating a plugin
|
|
|
|
|
471 |
*/
|
472 |
private function install() {
|
|
|
473 |
$installed_version = get_option( WC_Seq_Order_Number::VERSION_OPTION_NAME );
|
474 |
|
475 |
if ( ! $installed_version ) {
|
@@ -499,6 +557,8 @@ class WC_Seq_Order_Number {
|
|
499 |
|
500 |
foreach( $order_ids as $order_id ) {
|
501 |
|
|
|
|
|
502 |
if ( '' === get_post_meta( $order_id, '_order_number', true ) ) {
|
503 |
add_post_meta( $order_id, '_order_number', $order_id );
|
504 |
}
|
@@ -524,6 +584,8 @@ class WC_Seq_Order_Number {
|
|
524 |
|
525 |
/**
|
526 |
* Run when plugin version number changes
|
|
|
|
|
527 |
*/
|
528 |
private function upgrade( $installed_version ) {
|
529 |
// upgrade code goes here
|
@@ -546,6 +608,9 @@ function wc_sequential_order_numbers() {
|
|
546 |
|
547 |
/**
|
548 |
* The WC_Seq_Order_Number global object
|
|
|
|
|
|
|
549 |
* @deprecated 1.7.0
|
550 |
* @name $wc_seq_order_number
|
551 |
* @global WC_Seq_Order_Number $GLOBALS['wc_seq_order_number']
|
5 |
* Description: Provides sequential order numbers for WooCommerce orders
|
6 |
* Author: SkyVerge
|
7 |
* Author URI: http://www.skyverge.com
|
8 |
+
* Version: 1.8.0
|
9 |
* Text Domain: woocommerce-sequential-order-numbers
|
10 |
* Domain Path: /i18n/languages/
|
11 |
*
|
12 |
+
* Copyright: (c) 2012-2017, SkyVerge, Inc. (info@skyverge.com)
|
13 |
*
|
14 |
* License: GNU General Public License v3.0
|
15 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
17 |
* @package WC-Sequential-Order-Numbers
|
18 |
* @author SkyVerge
|
19 |
* @category Plugin
|
20 |
+
* @copyright Copyright (c) 2012-2017, SkyVerge, Inc.
|
21 |
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
|
22 |
*/
|
23 |
|
32 |
|
33 |
|
34 |
/** version number */
|
35 |
+
const VERSION = '1.8.0';
|
36 |
|
37 |
/** @var \WC_Seq_Order_Number single instance of this plugin */
|
38 |
protected static $instance;
|
41 |
const VERSION_OPTION_NAME = 'woocommerce_seq_order_number_db_version';
|
42 |
|
43 |
/** minimum required wc version */
|
44 |
+
const MINIMUM_WC_VERSION = '2.5.5';
|
45 |
|
46 |
|
47 |
/**
|
174 |
return 0;
|
175 |
}
|
176 |
|
177 |
+
if ( self::get_order_meta( $order, '_order_number' ) ) {
|
178 |
// _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
|
179 |
return 0;
|
180 |
}
|
181 |
|
182 |
+
return self::get_order_prop( $order, 'id' );
|
183 |
}
|
184 |
|
185 |
|
187 |
* Set the _order_number field for the newly created order
|
188 |
*
|
189 |
* @param int $post_id post identifier
|
190 |
+
* @param \WP_Post $post post object
|
191 |
*/
|
192 |
public function set_sequential_order_number( $post_id, $post ) {
|
193 |
global $wpdb;
|
194 |
|
195 |
if ( 'shop_order' === $post->post_type && 'auto-draft' !== $post->post_status ) {
|
196 |
|
197 |
+
$order = wc_get_order( $post_id );
|
198 |
+
$order_number = self::get_order_meta( $order, '_order_number' );
|
199 |
|
200 |
if ( '' === $order_number ) {
|
201 |
|
204 |
for ( $i = 0; $i < 3 && ! $success; $i++ ) {
|
205 |
|
206 |
// this seems to me like the safest way to avoid order number clashes
|
207 |
+
// By the time this is outdated, it's likely no longer needed anyway {BR 2017-03-08}
|
208 |
$query = $wpdb->prepare( "
|
209 |
INSERT INTO {$wpdb->postmeta} (post_id, meta_key, meta_value)
|
210 |
SELECT %d, '_order_number', IF( MAX( CAST( meta_value as UNSIGNED ) ) IS NULL, 1, MAX( CAST( meta_value as UNSIGNED ) ) + 1 )
|
229 |
*/
|
230 |
public function get_order_number( $order_number, $order ) {
|
231 |
|
232 |
+
if ( self::get_order_meta( $order, '_order_number' ) ) {
|
233 |
+
$order_number = self::get_order_meta( $order, '_order_number' );
|
234 |
}
|
235 |
|
236 |
return $order_number;
|
247 |
* @return array associative array of orderby parameteres
|
248 |
*/
|
249 |
public function woocommerce_custom_shop_order_orderby( $vars ) {
|
250 |
+
global $typenow;
|
251 |
|
252 |
+
if ( 'shop_order' !== $typenow ) {
|
253 |
return $vars;
|
254 |
}
|
255 |
|
311 |
/**
|
312 |
* Returns true if the installed version of WooCommerce Subscriptions is 2.0.0 or greater
|
313 |
*
|
314 |
+
* TODO: Drop Subs < 2.0 support with WC 3.1 compat {BR 2017-03-21}
|
315 |
+
*
|
316 |
* @since 1.5.1
|
317 |
* @return boolean
|
318 |
*/
|
325 |
* Sets an order number on a subscriptions-created order
|
326 |
*
|
327 |
* @since 1.3
|
328 |
+
* @param \WC_Order $renewal_order the new renewal order object
|
329 |
+
* @param \WC_Order $original_order the original order object (Subscriptions 2.0+: Subscription object)
|
330 |
+
* @return void|\WC_Order Void for Subscriptions 1.5, renewal order instance for Subscriptions 2.0+
|
331 |
*/
|
332 |
public function subscriptions_set_sequential_order_number( $renewal_order, $original_order ) {
|
333 |
|
392 |
}
|
393 |
|
394 |
|
395 |
+
/**
|
396 |
+
* Helper method to get order properties pre and post WC 3.0.
|
397 |
+
*
|
398 |
+
* TODO: Remove this when WooCommerce 3.0+ is required and remove helpers {BR 2017-03-08}
|
399 |
+
*
|
400 |
+
* @param \WC_Order $order the order for which to get data
|
401 |
+
* @param string $prop the order property to get
|
402 |
+
* @param string $context the context for the property, 'edit' or 'view'
|
403 |
+
* @return mixed the order property
|
404 |
+
*/
|
405 |
+
protected static function get_order_prop( WC_Order $order, $prop, $context = 'edit' ) {
|
406 |
+
|
407 |
+
$value = '';
|
408 |
+
|
409 |
+
if ( self::is_wc_version_gte_3_0() ) {
|
410 |
+
|
411 |
+
if ( is_callable( array( $order, "get_{$prop}" ) ) ) {
|
412 |
+
$value = $order->{"get_{$prop}"}( $context );
|
413 |
+
}
|
414 |
+
|
415 |
+
} else {
|
416 |
+
|
417 |
+
// if this is the 'view' context and there is an accessor method, use it
|
418 |
+
if ( is_callable( array( $order, "get_{$prop}" ) ) && 'view' === $context ) {
|
419 |
+
$value = $order->{"get_{$prop}"}();
|
420 |
+
} else {
|
421 |
+
$value = $order->$prop;
|
422 |
+
}
|
423 |
+
}
|
424 |
+
|
425 |
+
return $value;
|
426 |
+
}
|
427 |
|
428 |
|
429 |
/**
|
430 |
+
* Helper method to get order meta pre and post WC 3.0.
|
431 |
*
|
432 |
+
* TODO: Remove this when WooCommerce 3.0+ is required and remove helpers {BR 2017-03-08}
|
433 |
+
*
|
434 |
+
* @param \WC_Order $order the order object
|
435 |
+
* @param string $key the meta key
|
436 |
+
* @param bool $single whether to get the meta as a single item. Defaults to `true`
|
437 |
+
* @param string $context if 'view' then the value will be filtered
|
438 |
+
* @return mixed the order property
|
439 |
*/
|
440 |
+
protected static function get_order_meta( WC_Order $order, $key = '', $single = true, $context = 'edit' ) {
|
441 |
+
|
442 |
+
if ( self::is_wc_version_gte_3_0() ) {
|
443 |
+
|
444 |
+
$value = $order->get_meta( $key, $single, $context );
|
445 |
+
|
446 |
+
} else {
|
447 |
+
|
448 |
+
$order_id = is_callable( array( $order, 'get_id' ) ) ? $order->get_id() : $order->id;
|
449 |
+
$value = get_post_meta( $order_id, $key, $single );
|
450 |
+
|
451 |
+
}
|
452 |
+
|
453 |
+
return $value;
|
454 |
}
|
455 |
|
456 |
|
457 |
+
/** Compatibility Methods ******************************************************/
|
458 |
+
|
459 |
+
|
460 |
/**
|
461 |
+
* Helper method to get the version of the currently installed WooCommerce
|
462 |
*
|
463 |
+
* @since 1.3.2
|
464 |
+
* @return string woocommerce version number or null
|
465 |
*/
|
466 |
+
private static function get_wc_version() {
|
467 |
+
return defined( 'WC_VERSION' ) && WC_VERSION ? WC_VERSION : null;
|
468 |
}
|
469 |
|
470 |
|
471 |
/**
|
472 |
+
* Returns true if the installed version of WooCommerce is 3.0 or greater
|
473 |
*
|
474 |
+
* @since 1.8.0
|
475 |
+
* @return boolean true if the installed version of WooCommerce is 3.0 or greater
|
476 |
*/
|
477 |
+
private static function is_wc_version_gte_3_0() {
|
478 |
+
return self::get_wc_version() && version_compare( self::get_wc_version(), '3.0', '>=' );
|
479 |
}
|
480 |
|
481 |
|
523 |
|
524 |
/**
|
525 |
* Run every time. Used since the activation hook is not executed when updating a plugin
|
526 |
+
*
|
527 |
+
* @since 1.0.0
|
528 |
*/
|
529 |
private function install() {
|
530 |
+
|
531 |
$installed_version = get_option( WC_Seq_Order_Number::VERSION_OPTION_NAME );
|
532 |
|
533 |
if ( ! $installed_version ) {
|
557 |
|
558 |
foreach( $order_ids as $order_id ) {
|
559 |
|
560 |
+
// TODO: I'm not changing this right now so I don't have to instantiate a new order object for each update
|
561 |
+
// and if orders move away from posts this plugin doesn't matter anyway {BR 2017-03-08}
|
562 |
if ( '' === get_post_meta( $order_id, '_order_number', true ) ) {
|
563 |
add_post_meta( $order_id, '_order_number', $order_id );
|
564 |
}
|
584 |
|
585 |
/**
|
586 |
* Run when plugin version number changes
|
587 |
+
*
|
588 |
+
* 1.0.0
|
589 |
*/
|
590 |
private function upgrade( $installed_version ) {
|
591 |
// upgrade code goes here
|
608 |
|
609 |
/**
|
610 |
* The WC_Seq_Order_Number global object
|
611 |
+
*
|
612 |
+
* TODO: Remove the global with WC 3.1 compat {BR 2017-03-21}
|
613 |
+
*
|
614 |
* @deprecated 1.7.0
|
615 |
* @name $wc_seq_order_number
|
616 |
* @global WC_Seq_Order_Number $GLOBALS['wc_seq_order_number']
|