From b8f96b1ea21f0c7fa6c78897c91902d1d514b6e2 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Sun, 10 May 2015 21:50:50 +0200 Subject: [PATCH] Remove year variable from the free version; global/non-global counters are not required in the free version, then, either --- Makefile | 2 +- ordernumbers_woocommerce.php | 12 +++++++++ ordernumbers_woocommerce_basic.php | 41 ++++++++++++++---------------- readme.txt | 22 +++++++++++----- 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 089395a..8efe609 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BASE=ordernumbers PLATTFORM=woocommerce VENDOR=opentools -VERSION=1.0 +VERSION=1.1 DIR = $(shell pwd) diff --git a/ordernumbers_woocommerce.php b/ordernumbers_woocommerce.php index 213331f..e3e0729 100644 --- a/ordernumbers_woocommerce.php +++ b/ordernumbers_woocommerce.php @@ -55,6 +55,18 @@ class OpenToolsOrdernumbers extends OpenToolsOrdernumbersBasic { protected function getNumberFormatSettingsLabel() { return $this->helper->__( 'The format for the order numbers (variables can be entered as [...], the counter is indicated by the #). To use a different counter name than displayed, put the custom counter name after a |, e.g. "[year]-[month]/#|[year]" to use the month in the order number, but reset the counter only yearly. Advanced settings for the counter can be added as [#####:start/step], e.g. [#:100] to start new counters at 100, or [#/5] to increment the counter by 5. The number of # in the format determine how many digits are shown at least, e.g. [########] will always show at least 8 digits for the counter, e.g. 00000014.'); } + protected function addGlobalCounterSettings($settings) { + $settings[] = array( + 'title' => $this->helper->__( 'Use global counter'), + 'desc' => $this->helper->__( 'A global counter never resets. Non-global counters run within each number format and reset whenever any variable changes.'), + 'id' => 'ordernumber_global', + 'type' => 'checkbox', + 'default' => 'no', + ); + return $settings; + } + + protected function initializeSettingsOther() { return array_merge( $this->initializeSettingsInvoiceNumbers(), diff --git a/ordernumbers_woocommerce_basic.php b/ordernumbers_woocommerce_basic.php index 9825140..bc92b96 100644 --- a/ordernumbers_woocommerce_basic.php +++ b/ordernumbers_woocommerce_basic.php @@ -110,22 +110,22 @@ class OpenToolsOrdernumbersBasic { return $settings; } protected function initializeSettingsOrderNumbers() { - $settings = array( - array( + $settings = array(); + $settings[] = array( 'name' => $this->helper->__( 'Configure Order Numbers'), 'desc' => $this->helper->__( 'Configure the format and the counters of the order numbers in WooCommerce. For help, check out the plugin\'s <a href="http://open-tools.net/documentation/advanced-order-numbers-for-woocommerce.html">documentation at OpenTools</a>.'), 'type' => 'title', 'id' => 'ordernumber_options' - ), + ); - array( + $settings[] = array( 'name' => $this->helper->__( 'Customize Order Numbers'), 'desc' => $this->helper->__( 'Check to use custom order numbers rather than the default wordpress post ID.'), 'id' => 'customize_ordernumber', 'type' => 'checkbox', 'default' => 'no' - ), - array( + ); + $settings[] = array( 'title' => $this->helper->__( 'Order number format'), 'desc' => $this->getNumberFormatSettingsLabel(), 'desc_tip' => true, @@ -133,24 +133,18 @@ class OpenToolsOrdernumbersBasic { 'default' => '#', 'type' => 'text', 'css' => 'width: 100%', - ), - array( - 'title' => $this->helper->__( 'Use global counter'), - 'desc' => $this->helper->__( 'A global counter never resets. Non-global counters run within each number format and reset whenever any variable changes.'), - 'id' => 'ordernumber_global', - 'type' => 'checkbox', - 'default' => 'no', - ), - array( + ); + $settings = $this->addGlobalCounterSettings($settings); + $settings[] = array( 'name' => $this->helper->__( 'All order number counters'), 'desc' => $this->helper->__( 'View and modify the current counter values. The counter value is the value used for the previous number. All changes are immediately applied!'), 'desc_tip' => true, 'id' => 'ordernumber_counters', 'type' => 'ordernumber_counters', 'nrtype' => 'ordernumber', - ), - array( 'type' => 'sectionend', 'id' => 'ordernumber_options' ) - ); + ); + $settings[] = array('type' => 'sectionend', 'id' => 'ordernumber_options' ); + add_option ('customize_ordernumber', 'no'); add_option ('ordernumber_format', "#"); add_option ('ordernumber_global', 'no'); @@ -160,7 +154,10 @@ class OpenToolsOrdernumbersBasic { * Return the tooltip for the number format settings textinput (the two plugin versions have different features!) */ protected function getNumberFormatSettingsLabel() { - return $this->helper->__( 'The format for the order numbers: You can choose any text string, where the counter is indicated by # and variables by [...]. In the free version of the plugin, only the [year] and [year2] variables are available. For example, a format "WC-[year2]-#" will create order numbers "WC-15-01", "WC-15-02", "WC-15-03", ...'); + return $this->helper->__( 'The format for the order numbers: You can choose any text string, where the counter is indicated by #. For example, a format "WC-#" will create order numbers "WC-376", "WC-377", "WC-378", ...<br>In the <b>advanced version</b> of the plugin, variables can be indicated [...], e.g. [year].'); + } + protected function addGlobalCounterSettings($settings) { + return $settings; } protected function initializeSettingsOther() { @@ -375,9 +372,9 @@ class OpenToolsOrdernumbersBasic { /* Restrict date variables to years */ public function setupDateTimeReplacements (&$reps, $details, $nrtype) { - $utime = microtime(true); - $reps["[year]"] = date ("Y", $utime); - $reps["[year2]"] = date ("y", $utime); +// $utime = microtime(true); +// $reps["[year]"] = date ("Y", $utime); +// $reps["[year2]"] = date ("y", $utime); } function generateNumber($orderid, $order, $type='ordernumber') { diff --git a/readme.txt b/readme.txt index 1b9746e..45478d9 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Stable tag: trunk License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl.html -Customize order numbers for WooCommerce. The order numbers can contain arbitrary text, a running counter and the current year. +Customize order numbers for WooCommerce. The order numbers can contain arbitrary text and a running counter. == Description == @@ -15,15 +15,16 @@ The most flexible and complete solution for your WooCommerce webshop to customiz By default, WooCommerce uses the WordPress post ID of the order, which result in gaps between the order numbers. With this plugin you can configure the order numbers to have consecutive counters. Furthermore, the order number can contain the year, and the counter can be configured to reset each year. -The number format is a simple string, where # indicates the counter and [year] or [year2] indicate the year. -To get order numbers like "WC-2015-1", "WC-2015-2", etc., simply set the format to "WC-[year]-#". +The number format is a simple string, where # indicates the counter. +To get order numbers like "WC-376", "WC-377", "WC-378", etc., simply set the format to "WC-#". The plugin comes in two flavors: -* This **free basic version**, which provides **sequential numbers** and allows the **year in the order number** +* This **free basic version**, which provides **sequential numbers** and allows arbitrary text (prefix / postfix) in the numbers * The **paid advanced version**, with lots of **additional features**: - * Counter formatting: initial value, counter increments, number padding - * Lots of variables to be used in the formats + * Counter __formatting__: initial value, counter increments, number padding + * Flexible __counter resets__ + * Lots of __variables__ to be used in the formats - date/time: year, month, day, hour, etc. - address: customer country, zip, name, etc. - order-specific: Number of articles, products, order total etc. @@ -56,6 +57,10 @@ http://open-tools.net/documentation/advanced-order-numbers-for-woocommerce.html This plugin is intended for future orders. You can, however, create order numbers for existing orders in the order view in the WordPress admin section. In the top right "Order Actions" box select "Assign a new order number" and click "Save Order". Notice, however, that this will create an order number as if the order was created at that very moment. += How can I start the counter at a value higher than 1? = + +The easiest way is to configure the plugin, make one test order and then modify the counter in the plugin configuration to the value you desire. + = What about invoice numbers? = The Advanced Ordernumbers for WooCommerce plugin supports some invoicing plugins. This functionality is not available in the free version, though. @@ -63,10 +68,13 @@ The Advanced Ordernumbers for WooCommerce plugin supports some invoicing plugins == Screenshots == -1. == Changelog == += 1.1 = +* Some smaller bugfixes +* Removed variable definition for year + = 1.0 = * Initial release -- GitLab