Commit e64ecb94 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

V1.3.3: Fix order tracking, add trigger to return orderID given number

- Order tracking assumed the user entered the order ID => implement filter to convert the entered order number into the corresponding ID
- Added trigger woocommerce_order_id_from_number(ordernumber) that returns the order ID if found (if not found, returns ordernumber unchanged)
parent db43f3bf
BASE=ordernumbers
PLATTFORM=woocommerce
VENDOR=opentools
VERSION=1.3.2
VERSION=1.3.3
DIR = $(shell pwd)
SVNDIR=wordpress-plugin-svn
......
......@@ -97,6 +97,9 @@ class OpenToolsOrdernumbersBasic {
// The filter to actually return the order number for the given order
add_filter ('woocommerce_order_number', array( &$this, 'get_ordernumber'), 10, 2/*<= Also get the order object! */);
// Reverse searching (given the order number, return the order_id):
add_filter( 'woocommerce_shortcode_order_tracking_order_id', array( &$this, 'get_order_id_from_number' ) );
add_filter( 'woocommerce_order_id_from_number', array( &$this, 'get_order_id_from_number' ) );
}
......@@ -391,6 +394,20 @@ class OpenToolsOrdernumbersBasic {
$number = $this->assign_new_ordernumber($post_id, $post, $update);
}
}
public function get_order_id_from_number($ordernumber) {
global $wpdb;
$meta = $wpdb->get_results("SELECT * FROM `".$wpdb->postmeta."` WHERE meta_key='".esc_sql($this->ordernumber_meta.'ordernumber')."' AND meta_value='".esc_sql($ordernumber)."'");
if (is_array($meta) && !empty($meta) && isset($meta[0])) {
$meta = $meta[0];
}
if (is_object($meta)) {
return $meta->post_id;
} else {
return ordernumber;
}
}
/**
* AJAX Counter handling (simple loading/storing counters), storing them as options
......
......@@ -4,7 +4,7 @@ Contributors: opentools
Tags: WooCommerce, Order numbers, orders
Requires at least: 4.0
Tested up to: 4.5
Stable tag: 1.3.2
Stable tag: 1.3.3
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl.html
......@@ -78,6 +78,10 @@ The Advanced Ordernumbers for WooCommerce plugin supports some invoicing plugins
== Changelog ==
= 1.3.3 =
* Fix issue with order tracking (which assumed order IDs were entered)
* Add filter woocommerce_order_id_from_number(ordernumber) that returns the order ID given the order number
= 1.2.2 =
* Fix problem in the advanced version that no counters were shown in the counter modification table
......
......@@ -3,7 +3,7 @@
* Plugin Name: Woocommerce Advanced Ordernumbers
* Plugin URI: http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html
* Description: Lets the user freely configure the order numbers in WooCommerce.
* Version: 1.3.2
* Version: 1.3.3
* Author: Open Tools
* Author URI: http://open-tools.net
* Text Domain: woocommerce-advanced-ordernumbers
......
......@@ -3,7 +3,7 @@
* Plugin Name: WooCommerce Basic Ordernumbers
* Plugin URI: http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html
* Description: Configure WooCommerce ordernumbers to have a running counter and arbitrary, fixed text (prefix / postfix).
* Version: 1.3.2
* Version: 1.3.3
* Author: Open Tools
* Author URI: http://open-tools.net
* Text Domain: woocommerce-advanced-ordernumbers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment