Commit e383885c authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

Add readme.txt, fix issues with both versions installed, make it ready for the first release

parent 071d35c6
Material
sync.sh
.build
This diff is collapsed.
BASE=ordernumbers
PLATTFORM=woocommerce
VENDOR=opentools
VERSION=1.0
DIR = $(shell pwd)
BUILDDIR=.build/
BASICBUILDDIR=$(VENDOR)-$(PLATTFORM)-$(BASE)-basic
ADVBUILDDIR=$(VENDOR)-$(PLATTFORM)-$(BASE)-advanced
PLUGINFILES=library/ assets/ ordernumber_helper_woocommerce.php ordernumbers_woocommerce_basic.php readme.txt LICENSE.txt
BASICPLUGINFILES=woocommerce-custom-ordernumbers.php
ADVPLUGINFILES=woocommerce-advanced-ordernumbers.php ordernumbers_woocommerce.php
TRANSLATIONS=
ZIPFILE=$(VENDOR)-$(PLATTFORM)-$(BASE)-basic_v$(VERSION).zip
ADVZIPFILE=$(VENDOR)-$(PLATTFORM)-$(BASE)-advanced_v$(VERSION).zip
all: zip
zip: $(PLUGINFILES) $(ADVPLUGINFILES) $(BASICPLUGINFILES) $(TRANSLATIONS)
echo $(DIR)
@echo "Packing basic plugin version into distribution file $(ZIPFILE):"
mkdir -p $(BUILDDIR)/$(BASICBUILDDIR)
cp --parents -r $(PLUGINFILES) $(BASICPLUGINFILES) $(TRANSLATIONS) $(BUILDDIR)/$(BASICBUILDDIR)
cd $(BUILDDIR) && zip -r $(DIR)/$(ZIPFILE) $(BASICBUILDDIR)
# @zip -r
mkdir -p $(BUILDDIR)/$(ADVBUILDDIR)
echo `pwd`mak
cp --parents -r $(PLUGINFILES) $(ADVPLUGINFILES) $(TRANSLATIONS) $(BUILDDIR)/$(ADVBUILDDIR)
cp readme-adv.txt $(BUILDDIR)/$(ADVBUILDDIR)/readme.txt
cd $(BUILDDIR) && zip -r $(DIR)/$(ADVZIPFILE) $(ADVBUILDDIR)
cd $(DIR)
clean:
rm -f $(ZIPFILE) $(ADVZIPFILE) $(BUILDDIR) $(ADVBUILDDIR)
=== Advanced Ordernumbers ===
Contributors: opetools
Tags: WooCommerce, Order numbers, orders
Requires at least: 4.0
Tested up to: 4.1.1
Stable tag: trunk
License: GPLv2
Freely customize order numbers in WooCommerce. Lots of variables and counter settings can be used in the order number format.
== Description ==
Freely customize order numbers in WooCommerce. Lots of variables and counter settings can be used in the order number format.
\ No newline at end of file
div#opentools-ordernumber-upgrade {
/* margin-top: 1em; */
/* padding-left: 15px; */
/* border-radius: 5px; */
/* border: 1px solid red; */
/* background: #ff8080; */
padding: 5px 10px;
}
div#opentools-ordernumber-upgrade.postbox {
display: inline-block;
}
div#opentools-ordernumber-upgrade h3 {
margin-top: 5px;
margin-bottom: 5px;
padding: 0px 10px 5px 10px;
border-bottom: 1px solid #e0e0e0;
}
div#opentools-ordernumber-upgrade ul {
list-style: disc;
/* list-style-position: inside; */
margin-left: 5px;
padding-left: 5px;
}
div#opentools-ordernumber-upgrade li {
margin-left: 2em;
}
div#opentools-ordernumber-upgrade .column1, div#opentools-ordernumber-upgrade .column2 {
float: left;
}
div#opentools-ordernumber-upgrade .logoleft {
float: left;
padding-right: 10px;
position: absolute;
left: 15px;
}
div#opentools-ordernumber-upgrade .contents {
padding-left: 120px;
}
\ No newline at end of file
......@@ -9,6 +9,10 @@
if ( !defined( 'ABSPATH' ) && !defined('_JEXEC') ) {
die( 'Direct Access to ' . basename( __FILE__ ) . ' is not allowed.' );
}
// NULL function to indicate translatable strings without actually doing any translation
function trl($string) {
return $string;
}
class OrdernumberHelper {
static $_version = "0.1";
......@@ -19,6 +23,9 @@ class OrdernumberHelper {
'variable-table-class' => "",
'variable-table-style' => "",
);
protected $flags = array(
'extract-counter-settings' => 1,
);
/**
* An array containing all language keys for the translations used in the JavaScript code.
* Make sure to set those in the ajax_ordernumber JavaScript array!
......@@ -46,6 +53,20 @@ class OrdernumberHelper {
}
return $helper;
}
public function setFlag($flag, $value) {
$this->flags[$flag] = $value;
}
public function getFlag($flag, $default) {
if (isset($this->flags[$flag])) {
return $this->flags[$flag];
} else {
return $default;
}
}
public function unsetFlat($flag) {
unset($this->flags[$flag]);
}
function getStyle($key) {
if (isset($this->_styles[$key])) {
......@@ -206,7 +227,7 @@ class OrdernumberHelper {
return self::randomString ($alphabet, $len);
}
protected function setupDateTimeReplacements (&$reps, $details, $nrtype) {
public function setupDateTimeReplacements (&$reps, $details, $nrtype) {
$utime = microtime(true);
$reps["[year]"] = date ("Y", $utime);
$reps["[year2]"] = date ("y", $utime);
......@@ -314,41 +335,44 @@ class OrdernumberHelper {
}
protected function extractCounterSettings ($fmt, $type, $ctrsettings) {
// First, extract all counter settings, i.e. all strings of the form [#####:startval/increment] or [####/increment:startval]
$regexp = '%\[(#+)(/([0-9]+))?(:([0-9]+))?(/([0-9]+))?\]%';
$parts=array($fmt);
if ($this->getFlag('extract-counter-settings', true)) {
// First, extract all counter settings, i.e. all strings of the form [#####:startval/increment] or [####/increment:startval]
$regexp = '%\[(#+)(/([0-9]+))?(:([0-9]+))?(/([0-9]+))?\]%';
if (preg_match($regexp, $fmt, $counters)) {
// $counters is an array of the form:
// Array (
// [0] => [#####:100/3]
// [1] => #####
// [2] =>
// [3] =>
// [4] => :100
// [5] => 100
// [6] => /3
// [7] => 3
// )
$ctrsettings["${type}_padding"] = strlen($counters[1]);
if (!empty($counters[2])) {
// $counters[2] contains the whole "/n" part, while $counters[3] contains just the step itself
$ctrsettings["${type}_step"] = $counters[3];
}
if (!empty($counters[4])) {
// $counters[4] contains the whole ":n" part, while $counters[5] contains just the start value itself
$ctrsettings["${type}_start"] = $counters[5];
}
if (preg_match($regexp, $fmt, $counters)) {
// $counters is an array of the form:
// Array (
// [0] => [#####:100/3]
// [1] => #####
// [2] =>
// [3] =>
// [4] => :100
// [5] => 100
// [6] => /3
// [7] => 3
// )
$ctrsettings["${type}_padding"] = strlen($counters[1]);
if (!empty($counters[2])) {
// $counters[2] contains the whole "/n" part, while $counters[3] contains just the step itself
$ctrsettings["${type}_step"] = $counters[3];
}
if (!empty($counters[4])) {
// $counters[4] contains the whole ":n" part, while $counters[5] contains just the start value itself
$ctrsettings["${type}_start"] = $counters[5];
}
if (!empty($counters[6])) {
// $counters[6] contains the whole ":n" part, while $counters[7] contains just the start value itself
$ctrsettings["${type}_step"] = $counters[7];
}
if (!empty($counters[6])) {
// $counters[6] contains the whole ":n" part, while $counters[7] contains just the start value itself
$ctrsettings["${type}_step"] = $counters[7];
}
$fmt = preg_replace($regexp, "#", $fmt);
$fmt = preg_replace($regexp, "#", $fmt);
}
// Split at a | to get the number format and a possibly different counter increment format
// If a separate counter format is given after the |, use it, otherwise reuse the number format itself as counter format
$parts = explode ("|", $fmt);
}
// Split at a | to get the number format and a possibly different counter increment format
// If a separate counter format is given after the |, use it, otherwise reuse the number format itself as counter format
$parts = explode ("|", $fmt);
$ctrsettings["${type}_format"] = $parts[0];
$ctrsettings["${type}_counter"] = ($ctrsettings["${type}_global"]=='yes')?"":$parts[(count($parts)>1)?1:0];
......@@ -469,7 +493,7 @@ class OrdernumberHelper {
'variables_ifvar' => $this->__('PLG_ORDERNUMBER_REPL_IFVAR'),
'variables_ifop' => '',
'variables_ifval' => $this->__('PLG_ORDERNUMBER_REPL_IFVAL'),
'variables_then' => $this->__(''),
'variables_then' => '',
'variables_thenvar' => $this->__('PLG_ORDERNUMBER_REPL_SETVAR'),
'variables_thenval' => $this->__('PLG_ORDERNUMBER_REPL_TOVAL'),
'sort' => '',
......
......@@ -82,7 +82,6 @@ class OrdernumberHelperWooCommerce extends OrdernumberHelper {
if (sizeof($parts)==1) {
array_unshift($parts, 'ordernumber');
}
// print("<h1>$type Counter: $name with value $value encountered, prefix=".self::$ordernumber_counter_prefix.", parts=".print_r($parts,1)."</h1>");
if ($parts[0]==$type) {
$counters[] = array(
'type' => $parts[0],
......
This diff is collapsed.
This diff is collapsed.
=== WooCommerce Basic Ordernumbers ===
Contributors: opentools
Tags: WooCommerce, Order numbers, orders
Requires at least: 4.0
Tested up to: 4.1.1
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.
== Description ==
The most flexible and complete solution for your WooCommerce webshop to customize your order numbers!
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 plugin comes in two flavors:
* This **free basic version**, which provides **sequential numbers** and allows the **year in the order number**
* 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
- date/time: year, month, day, hour, etc.
- address: customer country, zip, name, etc.
- order-specific: Number of articles, products, order total etc.
- product categories, shipping method
* Custom variable definitions (with conditions on available variables)
* Multiple concurrent counters (e.g. numbering per country, per day, per ZIP, ...)
* Different order numbers for free orders (e.g. "FREE-01" for free orders)
* Different number format for e.g. certain IP addresses (for testing)
* Different number format depending on products, product categories, shipping classes
* Customize invoice numbers (only for the "WooCommerce PDF Invoices and Package Slips" plugin)
For the full documentation of both the basic and the advanced ordernumbers plugin for WooCommerce, see:
http://open-tools.net/documentation/advanced-order-numbers-for-woocommerce.html
== Installation ==
1. To install the plugin, either:
1. use WordPress' plugin manager to find it in the WordPress plugin directory and directly install it from the WP plugin manager, or
1. use WordPress' plugin manager to upload the plugin's zip file.
1. After installation, activate the plugin through the 'Plugins' menu in WordPress
1. Enable the plugin's functionality in the WooCommerce settings (tab "Checkout" -> "Order numbers")
== Frequently Asked Questions ==
= How can I create nice order numbers for existing orders? =
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.
= What about invoice numbers? =
The Advanced Ordernumbers for WooCommerce plugin supports some invoicing plugins. This functionality is not available in the free version, though.
== Screenshots ==
1.
== Changelog ==
= 1.0 =
* Initial release
== Upgrade Notice ==
To install the Advanced Ordernumbers for WooCommerce package, proceed as described in the Installation section.
No upgrades yet.
<?php
/**
* Plugin Name: Advanced Ordernumbers
* Plugin URI: http://open-tools.net/WooCommerce/Advanced-Ordernumbers.php
* 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: 0.1.0
* Author: Open Tools, Reinhold Kainhofer
* Version: 1.0
* Author: Open Tools
* Author URI: http://open-tools.net
* Text Domain: woocommerce-advanced-ordernumbers
* Domain Path:
......@@ -16,19 +16,29 @@ WC tested up to: 2.3
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
// Define a global flag so the basic plugin can deactivate itself if this plugin is loaded
if ( !defined('OPENTOOLS_ADVANCED_ORDERNUMBERS') ) {
define ('OPENTOOLS_ADVANCED_ORDERNUMBERS', true);
}
/**
* Check if WooCommerce is active
**/
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
require_once( plugin_dir_path( __FILE__ ) . '/ordernumber_helper_woocommerce.php');
if (!class_exists("OpenToolsOrdernumbers")) {
if (file_exists(plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce.php') && !class_exists("OpenToolsOrdernumbers")) {
require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce.php');
}
}
if (!class_exists("OpenToolsOrdernumbersBasic"))
require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php');
// instantiate the plugin class
if (class_exists("OpenToolsOrdernumbers")) {
// instantiate the plugin class
$ordernumber_plugin = new OpenToolsOrdernumbers();
$ordernumber_plugin = new OpenToolsOrdernumbers(plugin_basename(__FILE__));
} elseif (class_exists("OpenToolsOrdernumbersBasic")) {
$ordernumber_plugin = new OpenToolsOrdernumbersBasic(plugin_basename(__FILE__));
}
}
<?php
/**
* Plugin Name: WooCommerce Basic 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.0
* Author: Open Tools
* Author URI: http://open-tools.net
* Text Domain: woocommerce-advanced-ordernumbers
* Domain Path:
* License: GPL2+
WC requires at least: 2.2
WC tested up to: 2.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Check if WooCommerce is active
**/
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
if (file_exists(plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php') && !class_exists("OpenToolsOrdernumbersBasic") ) {
require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php');
}
function ordernumbers_print_basic_admin_notice() {
deactivate_plugins( plugin_basename( __FILE__ ) );
?>
<div class="error">
<p><?php _e( 'The <b>OpenTools Advanced Ordernumbers</b> plugin is <b>installed</b> and activated, the <b>basic ordernumber plugin</b> with similar, but limited functionality will be <b>deactivated</b>.', 'opentools-advanced-ordernumbers' ); ?></p>
</div>
<?php
}
function ordernumbers_check_deactivate() {
if (defined ('OPENTOOLS_ADVANCED_ORDERNUMBERS')) {
add_action( 'admin_notices', 'ordernumbers_print_basic_admin_notice');
}
}
add_action( 'plugins_loaded', 'ordernumbers_check_deactivate', 99 );
// instantiate the plugin class
if (class_exists("OpenToolsOrdernumbersBasic")) {
$ordernumber_plugin = new OpenToolsOrdernumbersBasic(plugin_basename(__FILE__));
}
}
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