Commit d0147994 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

V1.3.9: Fix issues with the WC PDF Invoices & Package Slips plugin (numbers...

V1.3.9: Fix issues with the WC PDF Invoices & Package Slips plugin (numbers were created even if disabled and even before invoices were actually created)
parent 9870271f
BASE=ordernumbers
PLATTFORM=woocommerce
VENDOR=opentools
VERSION=1.3.8
VERSION=1.3.9
DIR = $(shell pwd)
SVNDIR=wordpress-plugin-svn
......@@ -46,4 +46,4 @@ svn: $(SVNDIR)/trunk
svn-release: svn $(SVNDIR)/tags/$(VERSION)
rsync -avP $(PLUGINFILES) $(BASICPLUGINFILES) $(TRANSLATIONS) $(SVNDIR)/tags/$(VERSION)
\ No newline at end of file
......@@ -394,15 +394,18 @@ class OpenToolsOrdernumbers extends OpenToolsOrdernumbersBasic {
* creates a new invoice number if no entry exists in the database)
*/
function thirdparty_create_invoicenumber($default, $order) {
return $this->get_or_create_number($default, $order, 'invoice');
if ($this->invoicenumbers_activated()) {
return $this->get_or_create_number($default, $order, 'invoice');
} else {
return $default;
}
}
function thirdparty_get_invoicenumber($default, $orderid) {
if ($this->invoicenumbers_activated()) {
$_of = new WC_Order_Factory();
$order = $_of->get_order($orderid);
$number = $this->get_or_create_number($orderid, $order, 'invoice');
return $number;
return $this->get_number($orderid, $order, 'invoice');
} else {
return $default;
}
......@@ -424,9 +427,10 @@ class OpenToolsOrdernumbers extends OpenToolsOrdernumbersBasic {
* Initialize support for WPO WooCommerce PDF Invoices and Packaging Slips
*/
protected function thirdparty_wpo_wcpdf_init() {
// TODO: Wheck whether the woocommerce-pdf-invoices-packing-slips plugin is installed at all
add_filter ('wpo_wcpdf_invoice_number', array($this, 'thirdparty_wpo_wcpdf_invoice_number'), 30, 4);
add_action ('wpo_wcpdf_process_template_order', array($this, 'thirdparty_wpo_wcpdf_create_number'), 10, 2);
// Patch by OpenTools implements the generic interface, so nothing special needs to be done, except to include hints in the plugin config
// add_filter ('wpo_wcpdf_invoice_number', array($this, 'thirdparty_wpo_wcpdf_invoice_number'), 30, 4);
// add_action ('wpo_wcpdf_process_template_order', array($this, 'thirdparty_wpo_wcpdf_create_number'), 10, 2);
// Disable the invoice number-related controls in the config of the other plugin
add_action ('woocommerce_page_wpo_wcpdf_options_page', array($this, 'thirdparty_wpo_wcpdf_remove_options'));
// If this plugin is enabled, but invoice numbers are not, display an information message and a link to the config
......@@ -439,14 +443,18 @@ class OpenToolsOrdernumbers extends OpenToolsOrdernumbersBasic {
* created in the correct format, no need to format it now again)
*/
function thirdparty_wpo_wcpdf_invoice_number($invoice_number, $order_number, $order_id, $order_date) {
$_of = new WC_Order_Factory();
$order = $_of->get_order($order_id);
$nr = $this->get_or_create_number($order_id, $order, 'invoice');
if ($nr == $order_id) {
// No number was found, so the default is the order id => reset to invoice number
return $invoice_number;
if ($this->invoicenumbers_activated() ) {
$_of = new WC_Order_Factory();
$order = $_of->get_order($order_id);
$nr = $this->get_or_create_number($order_id, $order, 'invoice');
if ($nr == $order_id) {
// No number was found, so the default is the order id => reset to invoice number
return $invoice_number;
} else {
return $nr;
}
} else {
return $nr;
return $invoice_number;
}
}
/**
......
......@@ -494,6 +494,11 @@ class OpenToolsOrdernumbersBasic {
}
}
// Only retrieve the number, but do not create it if it doesn't exist:
function get_number($default, $order, $type = 'ordernumber') {
return get_post_meta( $order->id, $this->ordernumber_meta.$type, true);
}
/**
* Callback function for Woocommerce to retrieve the ordernumber for an order
* The hook to customize order numbers (requests the order number from the database;
......
......@@ -4,7 +4,7 @@ Contributors: opentools
Tags: WooCommerce, Order numbers, orders
Requires at least: 4.0
Tested up to: 4.7
Stable tag: 1.3.8
Stable tag: 1.3.9
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl.html
......@@ -78,6 +78,9 @@ The Advanced Ordernumbers for WooCommerce plugin supports some invoicing plugins
== Changelog ==
= 1.3.9 =
* Fix issues with the WooCommerce PDF Invoices & Packaging Slips plugin (invoice numbers were created even if disabled and before an invoice was actually generated)
= 1.3.8 =
* Add debug messages to the update system (disabled by default)
......
......@@ -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.8
* Version: 1.3.9
* 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.8
* Version: 1.3.9
* 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