Version Description
- 2016.02.04 =
- Misc - WooCommerce Subscriptions: Use new hook wcs_renewal_order_meta_query instead of deprecated woocommerce_subscriptions_renewal_order_meta_query
Download this release
Release Info
| Developer | SkyVerge |
| Plugin | |
| Version | 1.6.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.6.0 to 1.6.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.6.
|
| 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,14 +13,14 @@ msgstr ""
|
|
| 13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
| 14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
| 15 |
|
| 16 |
-
#: woocommerce-sequential-order-numbers.php:
|
| 17 |
#. Translators: %s - error message(s)
|
| 18 |
msgid ""
|
| 19 |
"Error activating and installing <strong>WooCommerce Sequential Order "
|
| 20 |
"Numbers</strong>: %s"
|
| 21 |
msgstr ""
|
| 22 |
|
| 23 |
-
#: woocommerce-sequential-order-numbers.php:
|
| 24 |
msgid "« Go Back"
|
| 25 |
msgstr ""
|
| 26 |
|
| 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.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:458
|
| 17 |
#. Translators: %s - error message(s)
|
| 18 |
msgid ""
|
| 19 |
"Error activating and installing <strong>WooCommerce Sequential Order "
|
| 20 |
"Numbers</strong>: %s"
|
| 21 |
msgstr ""
|
| 22 |
|
| 23 |
+
#: woocommerce-sequential-order-numbers.php:459
|
| 24 |
msgid "« Go Back"
|
| 25 |
msgstr ""
|
| 26 |
|
readme.txt
CHANGED
|
@@ -2,10 +2,10 @@
|
|
| 2 |
Contributors: SkyVerge, maxrice, tamarazuk, chasewiseman, nekojira
|
| 3 |
Tags: woocommerce, order number
|
| 4 |
Requires at least: 4.0
|
| 5 |
-
Tested up to: 4.4.
|
| 6 |
Requires WooCommerce at least: 2.3
|
| 7 |
Tested WooCommerce up to: 2.5
|
| 8 |
-
Stable tag: 1.6.
|
| 9 |
|
| 10 |
This plugin extends WooCommerce by setting sequential order numbers for new orders.
|
| 11 |
|
|
@@ -54,7 +54,10 @@ This free version does not have that functionality, but it's included in the pre
|
|
| 54 |
|
| 55 |
== Changelog ==
|
| 56 |
|
| 57 |
-
= 1.6.
|
|
|
|
|
|
|
|
|
|
| 58 |
* Misc - WooCommerce Subscriptions: Use new filter hook wcs_renewal_order_created instead of deprecated woocommerce_subscriptions_renewal_order_created
|
| 59 |
* Misc - WooCommerce 2.5 compatibility
|
| 60 |
* Misc - Dropped WooCommerce 2.2 support
|
| 2 |
Contributors: SkyVerge, maxrice, tamarazuk, chasewiseman, nekojira
|
| 3 |
Tags: woocommerce, order number
|
| 4 |
Requires at least: 4.0
|
| 5 |
+
Tested up to: 4.4.2
|
| 6 |
Requires WooCommerce at least: 2.3
|
| 7 |
Tested WooCommerce up to: 2.5
|
| 8 |
+
Stable tag: 1.6.1
|
| 9 |
|
| 10 |
This plugin extends WooCommerce by setting sequential order numbers for new orders.
|
| 11 |
|
| 54 |
|
| 55 |
== Changelog ==
|
| 56 |
|
| 57 |
+
= 1.6.1 - 2016.02.04 =
|
| 58 |
+
* Misc - WooCommerce Subscriptions: Use new hook wcs_renewal_order_meta_query instead of deprecated woocommerce_subscriptions_renewal_order_meta_query
|
| 59 |
+
|
| 60 |
+
= 1.6.0 - 2016.01.20 =
|
| 61 |
* Misc - WooCommerce Subscriptions: Use new filter hook wcs_renewal_order_created instead of deprecated woocommerce_subscriptions_renewal_order_created
|
| 62 |
* Misc - WooCommerce 2.5 compatibility
|
| 63 |
* Misc - Dropped WooCommerce 2.2 support
|
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.6.
|
| 9 |
* Text Domain: woocommerce-sequential-order-numbers
|
| 10 |
* Domain Path: /i18n/languages/
|
| 11 |
*
|
|
@@ -37,11 +37,12 @@ $GLOBALS['wc_seq_order_number'] = new WC_Seq_Order_Number();
|
|
| 37 |
|
| 38 |
class WC_Seq_Order_Number {
|
| 39 |
|
|
|
|
| 40 |
/** version number */
|
| 41 |
-
const VERSION =
|
| 42 |
|
| 43 |
/** version option name */
|
| 44 |
-
const VERSION_OPTION_NAME =
|
| 45 |
|
| 46 |
/** minimum required wc version */
|
| 47 |
const MINIMUM_WC_VERSION = '2.3';
|
|
@@ -72,24 +73,24 @@ class WC_Seq_Order_Number {
|
|
| 72 |
return;
|
| 73 |
}
|
| 74 |
|
| 75 |
-
//
|
| 76 |
-
//
|
| 77 |
-
add_action( 'wp_insert_post',
|
| 78 |
add_action( 'woocommerce_process_shop_order_meta', array( $this, 'set_sequential_order_number' ), 10, 2 );
|
| 79 |
|
| 80 |
// return our custom order number for display
|
| 81 |
-
add_filter( 'woocommerce_order_number',
|
| 82 |
|
| 83 |
// order tracking page search by order number
|
| 84 |
add_filter( 'woocommerce_shortcode_order_tracking_order_id', array( $this, 'find_order_by_order_number' ) );
|
| 85 |
|
| 86 |
-
// WC Subscriptions support
|
| 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( '
|
|
|
|
| 91 |
} else {
|
| 92 |
-
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
if ( is_admin() ) {
|
|
@@ -102,7 +103,7 @@ class WC_Seq_Order_Number {
|
|
| 102 |
}
|
| 103 |
|
| 104 |
// Installation
|
| 105 |
-
if ( is_admin() && !
|
| 106 |
$this->install();
|
| 107 |
}
|
| 108 |
}
|
|
@@ -166,16 +167,16 @@ class WC_Seq_Order_Number {
|
|
| 166 |
* Set the _order_number field for the newly created order
|
| 167 |
*
|
| 168 |
* @param int $post_id post identifier
|
| 169 |
-
* @param
|
| 170 |
*/
|
| 171 |
public function set_sequential_order_number( $post_id, $post ) {
|
| 172 |
global $wpdb;
|
| 173 |
|
| 174 |
-
if ( 'shop_order'
|
| 175 |
|
| 176 |
$order_number = get_post_meta( $post_id, '_order_number', true );
|
| 177 |
|
| 178 |
-
if (
|
| 179 |
|
| 180 |
// attempt the query up to 3 times for a much higher success rate if it fails (due to Deadlock)
|
| 181 |
$success = false;
|
|
@@ -226,7 +227,7 @@ class WC_Seq_Order_Number {
|
|
| 226 |
public function woocommerce_custom_shop_order_orderby( $vars ) {
|
| 227 |
global $typenow, $wp_query;
|
| 228 |
|
| 229 |
-
if ( 'shop_order'
|
| 230 |
return $vars;
|
| 231 |
}
|
| 232 |
|
|
@@ -319,18 +320,15 @@ class WC_Seq_Order_Number {
|
|
| 319 |
/**
|
| 320 |
* Don't copy over order number meta when creating a parent or child renewal order
|
| 321 |
*
|
|
|
|
|
|
|
|
|
|
| 322 |
* @since 1.3
|
| 323 |
* @param array $order_meta_query query for pulling the metadata
|
| 324 |
-
* @param int $original_order_id Post ID of the order being used to purchased the subscription being renewed
|
| 325 |
-
* @param int $renewal_order_id Post ID of the order created for renewing the subscription
|
| 326 |
-
* @param string $new_order_role The role the renewal order is taking, one of 'parent' or 'child'
|
| 327 |
* @return string
|
| 328 |
*/
|
| 329 |
-
public function subscriptions_remove_renewal_order_meta( $order_meta_query
|
| 330 |
-
|
| 331 |
-
$order_meta_query .= " AND meta_key NOT IN ( '_order_number' )";
|
| 332 |
-
|
| 333 |
-
return $order_meta_query;
|
| 334 |
}
|
| 335 |
|
| 336 |
|
|
@@ -402,7 +400,7 @@ class WC_Seq_Order_Number {
|
|
| 402 |
// if a plugin defines a minimum WC version, render a notice and skip loading the plugin
|
| 403 |
if ( defined( 'self::MINIMUM_WC_VERSION' ) && version_compare( self::get_wc_version(), self::MINIMUM_WC_VERSION, '<' ) ) {
|
| 404 |
|
| 405 |
-
if ( is_admin() && !
|
| 406 |
|
| 407 |
add_action( 'admin_notices', array( $this, 'render_update_notices' ) );
|
| 408 |
}
|
|
@@ -466,7 +464,7 @@ class WC_Seq_Order_Number {
|
|
| 466 |
|
| 467 |
foreach( $order_ids as $order_id ) {
|
| 468 |
|
| 469 |
-
if ( ''
|
| 470 |
add_post_meta( $order_id, '_order_number', $order_id );
|
| 471 |
}
|
| 472 |
}
|
|
@@ -477,10 +475,10 @@ class WC_Seq_Order_Number {
|
|
| 477 |
// and keep track of how far we made it in case we hit a script timeout
|
| 478 |
update_option( 'wc_sequential_order_numbers_install_offset', $offset );
|
| 479 |
|
| 480 |
-
} while ( count( $order_ids )
|
| 481 |
}
|
| 482 |
|
| 483 |
-
if ( $installed_version
|
| 484 |
$this->upgrade( $installed_version );
|
| 485 |
|
| 486 |
// new version number
|
| 5 |
* Description: Provides sequential order numbers for WooCommerce orders
|
| 6 |
* Author: SkyVerge
|
| 7 |
* Author URI: http://www.skyverge.com
|
| 8 |
+
* Version: 1.6.1
|
| 9 |
* Text Domain: woocommerce-sequential-order-numbers
|
| 10 |
* Domain Path: /i18n/languages/
|
| 11 |
*
|
| 37 |
|
| 38 |
class WC_Seq_Order_Number {
|
| 39 |
|
| 40 |
+
|
| 41 |
/** version number */
|
| 42 |
+
const VERSION = '1.6.1';
|
| 43 |
|
| 44 |
/** version option name */
|
| 45 |
+
const VERSION_OPTION_NAME = 'woocommerce_seq_order_number_db_version';
|
| 46 |
|
| 47 |
/** minimum required wc version */
|
| 48 |
const MINIMUM_WC_VERSION = '2.3';
|
| 73 |
return;
|
| 74 |
}
|
| 75 |
|
| 76 |
+
// Set the custom order number on the new order. we hook into wp_insert_post for orders which are created
|
| 77 |
+
// from the frontend, and we hook into woocommerce_process_shop_order_meta for admin-created orders
|
| 78 |
+
add_action( 'wp_insert_post', array( $this, 'set_sequential_order_number' ), 10, 2 );
|
| 79 |
add_action( 'woocommerce_process_shop_order_meta', array( $this, 'set_sequential_order_number' ), 10, 2 );
|
| 80 |
|
| 81 |
// return our custom order number for display
|
| 82 |
+
add_filter( 'woocommerce_order_number', array( $this, 'get_order_number' ), 10, 2 );
|
| 83 |
|
| 84 |
// order tracking page search by order number
|
| 85 |
add_filter( 'woocommerce_shortcode_order_tracking_order_id', array( $this, 'find_order_by_order_number' ) );
|
| 86 |
|
| 87 |
+
// WC Subscriptions support
|
|
|
|
|
|
|
| 88 |
if ( self::is_wc_subscriptions_version_gte_2_0() ) {
|
| 89 |
+
add_filter( 'wcs_renewal_order_meta_query', array( $this, 'subscriptions_remove_renewal_order_meta' ) );
|
| 90 |
+
add_filter( 'wcs_renewal_order_created', array( $this, 'subscriptions_set_sequential_order_number' ), 10, 2 );
|
| 91 |
} else {
|
| 92 |
+
add_filter( 'woocommerce_subscriptions_renewal_order_meta_query', array( $this, 'subscriptions_remove_renewal_order_meta' ) );
|
| 93 |
+
add_action( 'woocommerce_subscriptions_renewal_order_created', array( $this, 'subscriptions_set_sequential_order_number' ), 10, 2 );
|
| 94 |
}
|
| 95 |
|
| 96 |
if ( is_admin() ) {
|
| 103 |
}
|
| 104 |
|
| 105 |
// Installation
|
| 106 |
+
if ( is_admin() && ! is_ajax() ) {
|
| 107 |
$this->install();
|
| 108 |
}
|
| 109 |
}
|
| 167 |
* Set the _order_number field for the newly created order
|
| 168 |
*
|
| 169 |
* @param int $post_id post identifier
|
| 170 |
+
* @param WP_Post $post post object
|
| 171 |
*/
|
| 172 |
public function set_sequential_order_number( $post_id, $post ) {
|
| 173 |
global $wpdb;
|
| 174 |
|
| 175 |
+
if ( 'shop_order' === $post->post_type && 'auto-draft' !== $post->post_status ) {
|
| 176 |
|
| 177 |
$order_number = get_post_meta( $post_id, '_order_number', true );
|
| 178 |
|
| 179 |
+
if ( '' === $order_number ) {
|
| 180 |
|
| 181 |
// attempt the query up to 3 times for a much higher success rate if it fails (due to Deadlock)
|
| 182 |
$success = false;
|
| 227 |
public function woocommerce_custom_shop_order_orderby( $vars ) {
|
| 228 |
global $typenow, $wp_query;
|
| 229 |
|
| 230 |
+
if ( 'shop_order' === $typenow ) {
|
| 231 |
return $vars;
|
| 232 |
}
|
| 233 |
|
| 320 |
/**
|
| 321 |
* Don't copy over order number meta when creating a parent or child renewal order
|
| 322 |
*
|
| 323 |
+
* Prevents unnecessary order meta from polluting parent renewal orders,
|
| 324 |
+
* and set order number for subscription orders
|
| 325 |
+
*
|
| 326 |
* @since 1.3
|
| 327 |
* @param array $order_meta_query query for pulling the metadata
|
|
|
|
|
|
|
|
|
|
| 328 |
* @return string
|
| 329 |
*/
|
| 330 |
+
public function subscriptions_remove_renewal_order_meta( $order_meta_query ) {
|
| 331 |
+
return $order_meta_query . " AND meta_key NOT IN ( '_order_number' )";
|
|
|
|
|
|
|
|
|
|
| 332 |
}
|
| 333 |
|
| 334 |
|
| 400 |
// if a plugin defines a minimum WC version, render a notice and skip loading the plugin
|
| 401 |
if ( defined( 'self::MINIMUM_WC_VERSION' ) && version_compare( self::get_wc_version(), self::MINIMUM_WC_VERSION, '<' ) ) {
|
| 402 |
|
| 403 |
+
if ( is_admin() && ! is_ajax() && ! has_action( 'admin_notices', array( $this, 'render_update_notices' ) ) ) {
|
| 404 |
|
| 405 |
add_action( 'admin_notices', array( $this, 'render_update_notices' ) );
|
| 406 |
}
|
| 464 |
|
| 465 |
foreach( $order_ids as $order_id ) {
|
| 466 |
|
| 467 |
+
if ( '' === get_post_meta( $order_id, '_order_number', true ) ) {
|
| 468 |
add_post_meta( $order_id, '_order_number', $order_id );
|
| 469 |
}
|
| 470 |
}
|
| 475 |
// and keep track of how far we made it in case we hit a script timeout
|
| 476 |
update_option( 'wc_sequential_order_numbers_install_offset', $offset );
|
| 477 |
|
| 478 |
+
} while ( count( $order_ids ) === $posts_per_page ); // while full set of results returned (meaning there may be more results still to retrieve)
|
| 479 |
}
|
| 480 |
|
| 481 |
+
if ( $installed_version !== WC_Seq_Order_Number::VERSION ) {
|
| 482 |
$this->upgrade( $installed_version );
|
| 483 |
|
| 484 |
// new version number
|
