WooCommerce Sequential Order Numbers - Version 1.2.4

Version Description

  • WordPress 3.5 compatibility fix
  • Order numbers not assigned to temporary auto-draft orders created from the admin
Download this release

Release Info

Developer FoxRunSoftware
Plugin Icon WooCommerce Sequential Order Numbers
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.2.3 to 1.2.4

readme.txt CHANGED
@@ -2,8 +2,8 @@
2
Contributors: FoxRunSoftware
3
Tags: woocommerce, order number
4
Requires at least: 3.3
5
- Tested up to: 3.3
6
- Stable tag: 1.2.3
7
8
This plugin extends the WooCommerce e-commerce plugin by setting sequential order numbers for new orders.
9
@@ -11,7 +11,7 @@ This plugin extends the WooCommerce e-commerce plugin by setting sequential orde
11
12
This plugin extends the WooCommerce e-commerce plugin by 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.
13
14
- 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 my newly released paid WooCommerce Sequential Order Numbers Pro plugin, available from the [WooThemes Store](http://www.woothemes.com/extension/sequential-order-numbers-pro/)
15
16
This plugin requires WooCommerce 1.5.6 or greater.
17
@@ -21,7 +21,7 @@ This plugin requires WooCommerce 1.5.6 or greater.
21
22
= More =
23
* Vist the [WooCommerce Sequential Order Number plugin page](http://www.foxrunsoftware.net/articles/wordpress/woocommerce-sequential-order-numbers/) for further details and a discussion of the implementation. [Also see my other plugins](http://www.foxrunsoftware.com) or see [my WordPress.org profile page](http://profiles.wordpress.org/foxrunsoftware/)
24
- * Find the enhanced WooCommerce Sequential Order Numbers Pro now available from [WooThemes](http://www.woothemes.com/extension/sequential-order-numbers-pro/)
25
26
== Installation ==
27
@@ -33,14 +33,18 @@ This plugin requires WooCommerce 1.5.6 or greater.
33
34
= Can I start the order numbers at a particular number? =
35
36
- This free version does not have that functionality, but now you can with the paid [WooCommerce Sequential Order Numbers Pro](http://www.woothemes.com/extension/sequential-order-numbers-pro/)
37
38
= Can I set an order number prefix/suffix? =
39
40
- This free version does not have that functionality, but now you can with the paid [WooCommerce Sequential Order Numbers Pro](http://www.woothemes.com/extension/sequential-order-numbers-pro/)
41
42
== Changelog ==
43
44
= 1.2.3 =
45
* Removed WooCommerce functions, which caused a compatibility issue with other WooCommerce plugins
46
2
Contributors: FoxRunSoftware
3
Tags: woocommerce, order number
4
Requires at least: 3.3
5
+ Tested up to: 3.5
6
+ Stable tag: 1.2.4
7
8
This plugin extends the WooCommerce e-commerce plugin by setting sequential order numbers for new orders.
9
11
12
This plugin extends the WooCommerce e-commerce plugin by 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.
13
14
+ 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 my newly released paid WooCommerce Sequential Order Numbers Pro plugin, available from the [WooThemes Store](http://www.woothemes.com/products/sequential-order-numbers-pro/)
15
16
This plugin requires WooCommerce 1.5.6 or greater.
17
21
22
= More =
23
* Vist the [WooCommerce Sequential Order Number plugin page](http://www.foxrunsoftware.net/articles/wordpress/woocommerce-sequential-order-numbers/) for further details and a discussion of the implementation. [Also see my other plugins](http://www.foxrunsoftware.com) or see [my WordPress.org profile page](http://profiles.wordpress.org/foxrunsoftware/)
24
+ * Find the enhanced WooCommerce Sequential Order Numbers Pro now available from [WooThemes](http://www.woothemes.com/products/sequential-order-numbers-pro/)
25
26
== Installation ==
27
33
34
= Can I start the order numbers at a particular number? =
35
36
+ This free version does not have that functionality, but now you can with the paid [WooCommerce Sequential Order Numbers Pro](http://www.woothemes.com/products/sequential-order-numbers-pro/)
37
38
= Can I set an order number prefix/suffix? =
39
40
+ This free version does not have that functionality, but now you can with the paid [WooCommerce Sequential Order Numbers Pro](http://www.woothemes.com/products/sequential-order-numbers-pro/)
41
42
== Changelog ==
43
44
+ = 1.2.4 =
45
+ * WordPress 3.5 compatibility fix
46
+ * Order numbers not assigned to temporary auto-draft orders created from the admin
47
+
48
= 1.2.3 =
49
* Removed WooCommerce functions, which caused a compatibility issue with other WooCommerce plugins
50
woocommerce-sequential-order-numbers.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.foxrunsoftware.net/articles/wordpress/woocommerce-sequent
5
Description: Provides sequential order numbers for WooCommerce orders
6
Author: Justin Stern
7
Author URI: http://www.foxrunsoftware.net
8
- Version: 1.2.3
9
10
Copyright: � 2012 Justin Stern (email : justin@foxrunsoftware.net)
11
License: GNU General Public License v3.0
@@ -20,13 +20,15 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
20
if ( ! class_exists( 'WC_Seq_Order_Number' ) ) {
21
22
class WC_Seq_Order_Number {
23
- const VERSION = "1.2.3";
24
const VERSION_OPTION_NAME = "woocommerce_seq_order_number_db_version";
25
26
public function __construct() {
27
28
- // set the custom order number on the new order
29
add_action( 'wp_insert_post', array( &$this, 'set_sequential_order_number' ), 10, 2 );
30
31
// return our custom order number for display
32
add_filter( 'woocommerce_order_number', array( &$this, 'get_order_number' ), 10, 2);
@@ -88,7 +90,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
88
public function set_sequential_order_number( $post_id, $post ) {
89
global $wpdb;
90
91
- if ( $post->post_type == 'shop_order' ) {
92
$order_number = get_post_meta( $post_id, '_order_number', true );
93
if ( $order_number == "" ) {
94
@@ -96,7 +98,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
96
$success = false;
97
for ( $i = 0; $i < 3 && ! $success; $i++ ) {
98
// this seems to me like the safest way to avoid order number clashes
99
- $success = $wpdb->query( $wpdb->prepare( 'INSERT INTO ' . $wpdb->postmeta . ' (post_id,meta_key,meta_value) SELECT ' . $post_id . ',"_order_number",if(max(cast(meta_value as UNSIGNED)) is null,1,max(cast(meta_value as UNSIGNED))+1) from ' . $wpdb->postmeta . ' where meta_key="_order_number"' ) );
100
}
101
}
102
}
5
Description: Provides sequential order numbers for WooCommerce orders
6
Author: Justin Stern
7
Author URI: http://www.foxrunsoftware.net
8
+ Version: 1.2.4
9
10
Copyright: � 2012 Justin Stern (email : justin@foxrunsoftware.net)
11
License: GNU General Public License v3.0
20
if ( ! class_exists( 'WC_Seq_Order_Number' ) ) {
21
22
class WC_Seq_Order_Number {
23
+ const VERSION = "1.2.4";
24
const VERSION_OPTION_NAME = "woocommerce_seq_order_number_db_version";
25
26
public function __construct() {
27
28
+ // set the custom order number on the new order. we hook into wp_insert_post for orders which are created
29
+ // from the frontend, and we hook into woocommerce_process_shop_order_meta for admin-created orders
30
add_action( 'wp_insert_post', array( &$this, 'set_sequential_order_number' ), 10, 2 );
31
+ add_action( 'woocommerce_process_shop_order_meta', array( &$this, 'set_sequential_order_number' ), 10, 2 );
32
33
// return our custom order number for display
34
add_filter( 'woocommerce_order_number', array( &$this, 'get_order_number' ), 10, 2);
90
public function set_sequential_order_number( $post_id, $post ) {
91
global $wpdb;
92
93
+ if ( $post->post_type == 'shop_order' && $post->post_status != 'auto-draft' ) {
94
$order_number = get_post_meta( $post_id, '_order_number', true );
95
if ( $order_number == "" ) {
96
98
$success = false;
99
for ( $i = 0; $i < 3 && ! $success; $i++ ) {
100
// this seems to me like the safest way to avoid order number clashes
101
+ $success = $wpdb->query( 'INSERT INTO ' . $wpdb->postmeta . ' (post_id,meta_key,meta_value) SELECT ' . $post_id . ',"_order_number",if(max(cast(meta_value as UNSIGNED)) is null,1,max(cast(meta_value as UNSIGNED))+1) from ' . $wpdb->postmeta . ' where meta_key="_order_number"' );
102
}
103
}
104
}