Commit d3076e9a authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

Implement invoice numbers for wpo wcpdf invoices and packaging slips

parent 41d40415
......@@ -38,3 +38,18 @@ woocommerce_new_order', $order_id );
Order created in BackEnd:
Created: wp_insert_post => Assign placeholder (no address yet)
Modified:
TODO:
Check order/invoice numbers for renewals: https://wordpress.org/support/topic/subscription-renewal-duplicate-invoice-number?replies=6#post-6138110
INVOICES:
=========
woocommerce-pdf-invoices-packing-slips:
-) Uses order_meta: _wcpdf_invoice_number => Set it manually to prevent the plugin from using its own counter
-) Calls filter wpo_wcpdf_invoice_number($invoice_number, $order_number, $order_id, $order_data) to format the invoice number.
-) Triggers before PDF creation: wp_wcpdf_before_pdf, wpo_wcpdf_process_order_ids, wpo_wcpdf_process_template_order($template_type, $order_id)
......@@ -7,9 +7,23 @@ jQuery( function ( $ ) {
if ($(this).is(':checked')) {
$('#ordernumber_format').closest('tr').show();
$('#ordernumber_global').closest('tr').show();
$('#ordernumber-countertable-ordernumber').closest('tr').show();
} else {
$('#ordernumber_format').closest('tr').hide();
$('#ordernumber_global').closest('tr').hide();
$('#ordernumber-countertable-ordernumber').closest('tr').hide();
}
}).change();
$('input#customize_invoice').change(function() {
if ($(this).is(':checked')) {
$('#invoice_format').closest('tr').show();
$('#invoice_global').closest('tr').show();
$('#ordernumber-countertable-invoice').closest('tr').show();
} else {
$('#invoice_format').closest('tr').hide();
$('#invoice_global').closest('tr').hide();
$('#ordernumber-countertable-invoice').closest('tr').hide();
}
}).change();
......
......@@ -39,6 +39,14 @@ class OrdernumberHelper {
$this->registerCallback ("setupDateTimeReplacements", array($this, "setupDateTimeReplacements"));
}
static function getHelper() {
static $helper = null;
if (!$helper) {
$helper = new OrdernumberHelper();
}
return $helper;
}
function getStyle($key) {
if (isset($this->_styles[$key])) {
return $this->_styles[$key];
......@@ -388,7 +396,7 @@ class OrdernumberHelper {
public function counter_modification_create_table($type, $counters) {
$html=array();
$html[] = "<img src='" . $this->urlPath ('images', 'loading.gif') . "' class='ordernumber-loading' />";
$html[] = "<table class=\"ordernumber-countertable " . $this->getStyle('counter-table-class') . "\" " . $this->getStyle('counter-table-style') . ">";
$html[] = "<table class=\"ordernumber-countertable " . $this->getStyle('counter-table-class') . "\" " . $this->getStyle('counter-table-style') . " id='ordernumber-countertable-" . $type . "'>";
$html[] = "<thead>";
$html[] = " <tr>";
$html[] = " <th class='counter_format'>" . $this->__ ('PLG_ORDERNUMBER_COUNTERLIST_HEADER_COUNTER')."</th>";
......@@ -560,4 +568,30 @@ var ajax_ordernumber = ' . json_encode($json) . ';
return $js;
}
public function ajax_counter_delete($type, $counter) {
// TODO: Check if counter value has changed meanwhile
$json = array('action' => 'delete_counter', 'success' => 0);
$json['success'] = $this->deleteCounter($type, $counter);
return $json;
}
public function ajax_counter_add ($type, $counter, $value) {
// TODO: Check if counter value has changed meanwhile
$json = array('action' => 'add_counter', 'success' => 0);
if ($this->getCounter($type, $counter, -1) != -1) {
// Counter already exists => error message
$json['error'] = sprintf($this->__('Counter "%s" already exists, cannot create again.'), $counter);
} else {
$json['success'] = $this->setCounter($type, $counter, $value);
$json['row'] = $this->counter_modification_create_row($type, $counter, $value);
}
return $json;
}
public function ajax_counter_set ($type, $counter, $value) {
$json = array('action' => 'set_counter', 'success' => 0);
$json['success'] = $this->setCounter($type, $counter, $value);
$json['row'] = $this->counter_modification_create_row($type, $counter, $value);
return $json;
}
}
This diff is collapsed.
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