Commit d04cca42 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

V1.3.1: Support for generic invoice number API...

V1.3.1: Support for generic invoice number API (http://www.open-tools.net/blog/63-proposal-for-a-general-api-for-third-party-woocommerce-invoice-numbering-plugins.html); Implementation for five different invoicing plugins
parent 083f6d8c
......@@ -374,7 +374,7 @@ 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_data) {
$nr = $this->get_number($order_id, $order_data, 'invoice');
$nr = $this->get_or_create_number($order_id, $order_data, 'invoice');
if ($nr == $order_id) {
// No number was found, so the default is the order id => reset to invoice number
return $invoice_number;
......
......@@ -477,14 +477,17 @@ class OpenToolsOrdernumbersBasic {
}
}
/**
* The generic function to retrieve a particular number
/**
* Callback function for Woocommerce to retrieve the ordernumber for an order
* The hook to customize order numbers (requests the order number from the database;
* creates a new ordernumber if no entry exists in the database)
*/
function get_number($default, $order, $type = 'ordernumber') {
$stored_number = get_post_meta( $order->id, $this->ordernumber_meta.$type, 'true');
function get_ordernumber($orderid, $order) {
$type = 'ordernumber';
$stored_number = get_post_meta( $orderid, $this->ordernumber_meta.$type, 'true');
if ($stored_number == $this->ordernumber_new_placeholder) {
// Check whether the order was now really created => create order number now
return $this->assign_new_ordernumber($order->id, $order, $type);
return $this->assign_new_ordernumber($orderid, $order);
} elseif (!empty($stored_number)) {
// Order number already exists => simply return it
return $stored_number;
......@@ -493,14 +496,5 @@ class OpenToolsOrdernumbersBasic {
return $default;
}
}
/**
* Callback function for Woocommerce to retrieve the ordernumber for an order
* The hook to customize order numbers (requests the order number from the database;
* creates a new ordernumber if no entry exists in the database)
*/
function get_ordernumber($orderid, $order) {
return $this->get_number($orderid, $order, 'ordernumber');
}
}
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