diff --git a/plugins/template/Makefile b/plugins/template/Makefile index 57931331c8de4fc95a3edefa12b85a323a824b46..c4f8a960385d76955dd5d0c1189375b41bd15c61 100644 --- a/plugins/template/Makefile +++ b/plugins/template/Makefile @@ -9,21 +9,10 @@ BUILDDIR=.build/ PLUGINFILES=$(BASE).php readme.txt LICENSE.txt TRANSLATIONS= -ZIPFILE=$(PLATTFORM)-$(BASE)-v$(VERSION).zip +ZIPFILE=$(BASE)-v$(VERSION).zip all: zip -zip: $(PLUGINFILES) $(TRANSLATIONS) $(ADVANCEDFILES) $(INDEXFILES) - @echo "Packing all files into distribution file $(ZIPFILE):" - @zip -r $(ZIPFILE) $(PLUGINFILES) $(TRANSLATIONS) $(INDEXFILES) $(FIELDS) - -clean: - rm -f $(ZIPFILE) - - - - - zip: $(PLUGINFILES) $(TRANSLATIONS) @echo "Packing plugin into distribution file $(ZIPFILE):" @mkdir -p $(BUILDDIR)/$(BASE) diff --git a/plugins/template/YOUR_PLUGIN_NAME.php b/plugins/template/YOUR_PLUGIN_NAME.php index 744fab2e9d9e944f85c43392929846ec1beacd51..b4a2ab2414acac0ff0ea11e18de28fcba5479812 100644 --- a/plugins/template/YOUR_PLUGIN_NAME.php +++ b/plugins/template/YOUR_PLUGIN_NAME.php @@ -1,6 +1,6 @@ <?php /** - * Plugin Name: YOUR_PLUGIN_NAME extension plugin for OpenTools Basic/Advanced Ordernumbers for WooCommerce + * Plugin Name: YOUR_PLUGIN_NAME Ordernumber extension for WC * Plugin URI: http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html * Description: A sample template for an extension plugin for the OpenTools Basic / Advanced Ordernumber for WooCommerce plugin. This extension plugin can provide additional variables, modify existing variables and post-process the generated numbers. * Version: 1.0 @@ -29,12 +29,12 @@ if ( ! defined( 'ABSPATH' ) ) { */ add_filter('opentools_ordernumber_replacements', "ordernumber_replacements_YOUR_PLUGIN_NAME", 10, 3); -ordernumber_replacements_YOUR_PLUGIN_NAME($reps, $details, $nrtype) { +function ordernumber_replacements_YOUR_PLUGIN_NAME($reps, $details, $nrtype) { $userid = $details->get_user_id(); // Case 1: Return the number of orders this user has already posted (+1, // because the current order is not yet registered with WC!) - $reps['[userordercount]'] = wc_get_customer_order_count($userid)+1; + $reps['[userordercount]'] = wc_get_customer_order_count($userid); // Case 2: Add a [Type] variable that holds either "ordernumber" or "invoice" $reps['[type]'] = $nrtype; diff --git a/plugins/template/readme.txt b/plugins/template/readme.txt index 6debd4a582f6b34095f8d101bab331f990d7c03c..7761ba445778f1d226f90e7a7b5e50b83559bcc2 100644 --- a/plugins/template/readme.txt +++ b/plugins/template/readme.txt @@ -1,4 +1,4 @@ -=== YOUR_PLUGIN_NAME extension for OpenTools Ordernumbers for WooCommerce === +=== YOUR_PLUGIN_NAME Ordernumber extension for WC === Plugin Name: YOUR_PLUGIN_NAME extension for OpenTools Ordernumbers for WooCommerce Contributors: opentools Tags: WooCommerce, Order numbers, orders diff --git a/plugins/user_order_count/woocommerce-user_order_count-v1.0.zip b/plugins/template/releases/ordernumbers-extension-template-v1.0.zip similarity index 81% rename from plugins/user_order_count/woocommerce-user_order_count-v1.0.zip rename to plugins/template/releases/ordernumbers-extension-template-v1.0.zip index 82603c22b8140090dba6f7eac3399c5e361d5684..0006f0b7fe63b0eafec1f1dfc24a12df82bd0b18 100644 Binary files a/plugins/user_order_count/woocommerce-user_order_count-v1.0.zip and b/plugins/template/releases/ordernumbers-extension-template-v1.0.zip differ diff --git a/plugins/user_order_count/Makefile b/plugins/user_order_count/Makefile deleted file mode 100644 index 3d23ad370d2e33e2fb51062eadbb383b3ec07142..0000000000000000000000000000000000000000 --- a/plugins/user_order_count/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -BASE=user_order_count -PLATTFORM=woocommerce -VENDOR=opentools -VERSION=1.0 - -PLUGINFILES=$(BASE).php readme.txt LICENSE.txt - -TRANSLATIONS= -ZIPFILE=$(PLATTFORM)-$(BASE)-v$(VERSION).zip - -all: zip - -zip: $(PLUGINFILES) $(TRANSLATIONS) $(ADVANCEDFILES) $(INDEXFILES) - @echo "Packing all files into distribution file $(ZIPFILE):" - @zip -r $(ZIPFILE) $(PLUGINFILES) $(TRANSLATIONS) $(INDEXFILES) $(FIELDS) - -clean: - rm -f $(ZIPFILE) diff --git a/plugins/user_order_count/LICENSE.txt b/plugins/woocommerce-ordernumber-userordercount/LICENSE.txt similarity index 100% rename from plugins/user_order_count/LICENSE.txt rename to plugins/woocommerce-ordernumber-userordercount/LICENSE.txt diff --git a/plugins/woocommerce-ordernumber-userordercount/Makefile b/plugins/woocommerce-ordernumber-userordercount/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..8ef2bfd2ca71128c89fad900625f02313515404b --- /dev/null +++ b/plugins/woocommerce-ordernumber-userordercount/Makefile @@ -0,0 +1,24 @@ +BASE=woocommerce-ordernumber-userordercount +PLATTFORM=woocommerce +VENDOR=opentools +VERSION=1.0 + +DIR = $(shell pwd) +BUILDDIR=.build/ + +PLUGINFILES=$(BASE).php readme.txt LICENSE.txt + +TRANSLATIONS= +ZIPFILE=$(BASE)-v$(VERSION).zip + +all: zip + +zip: $(PLUGINFILES) $(TRANSLATIONS) + @echo "Packing plugin into distribution file $(ZIPFILE):" + @mkdir -p $(BUILDDIR)/$(BASE) + @cp --parents -r $(PLUGINFILES) $(TRANSLATIONS) $(BUILDDIR)/$(BASE)/ + cd $(BUILDDIR) && zip -r $(DIR)/$(ZIPFILE) $(BASE) + cd $(DIR) + +clean: + rm -rf $(ZIPFILE) $(BUILDDIR) diff --git a/plugins/user_order_count/readme.txt b/plugins/woocommerce-ordernumber-userordercount/readme.txt similarity index 66% rename from plugins/user_order_count/readme.txt rename to plugins/woocommerce-ordernumber-userordercount/readme.txt index 7fb61cccda4650b2849e97105f8310a6a58be697..1d48b808bf49d560432c37ee2eb4a65d7c0ff2ba 100644 --- a/plugins/user_order_count/readme.txt +++ b/plugins/woocommerce-ordernumber-userordercount/readme.txt @@ -1,5 +1,5 @@ -=== User_order_count extension for OpenTools Ordernumbers for WooCommerce === -Plugin Name: User_order_count extension for OpenTools Ordernumbers for WooCommerce +=== UserOrderCount Ordernumber extension for WC === +Plugin Name: UserOrderCount extension for OpenTools Ordernumbers for WooCommerce Contributors: opentools Tags: WooCommerce, Order numbers, orders Requires at least: 4.0 @@ -8,15 +8,15 @@ Stable tag: 1.0 License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl.html -Extension plugin for the OpenTools Basic/Advanced Ordernumbers for WooCommerce. -Custom variables can be provided. - +An extension plugin for the OpenTools Basic / Advanced Ordernumber for WooCommerce +plugin that adds the number of orders the user has already posted in the +variable UserOrderCount. == Description == -This extension plugin is a template to show how custom plugins can add new variables -for use in the order/invoice numbers generated by the OpenTools Basic/Advanced -Ordernumbers plugin for WooCommerce. +An extension plugin for the OpenTools Basic / Advanced Ordernumber for WooCommerce +plugin that adds the number of orders the user has already posted in the +variable UserOrderCount. 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 diff --git a/plugins/woocommerce-ordernumber-userordercount/woocommerce-ordernumber-userordercount-v1.0.zip b/plugins/woocommerce-ordernumber-userordercount/woocommerce-ordernumber-userordercount-v1.0.zip new file mode 100644 index 0000000000000000000000000000000000000000..91688a07d61f25b2bd4326db94e5fe14460dacf0 Binary files /dev/null and b/plugins/woocommerce-ordernumber-userordercount/woocommerce-ordernumber-userordercount-v1.0.zip differ diff --git a/plugins/user_order_count/user_order_count.php b/plugins/woocommerce-ordernumber-userordercount/woocommerce-ordernumber-userordercount.php similarity index 53% rename from plugins/user_order_count/user_order_count.php rename to plugins/woocommerce-ordernumber-userordercount/woocommerce-ordernumber-userordercount.php index 1bac40144add7ea5e306b3e52ca885801d6b5ee0..249917d2f2d409dbf667b59756b573362d647a92 100644 --- a/plugins/user_order_count/user_order_count.php +++ b/plugins/woocommerce-ordernumber-userordercount/woocommerce-ordernumber-userordercount.php @@ -1,12 +1,14 @@ <?php /** - * Plugin Name: User_order_count extension plugin for OpenTools Basic/Advanced Ordernumbers for WooCommerce + * Plugin Name: UserOrderCount Ordernumber extension for WC * Plugin URI: http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html - * Description: A sample template for an extension plugin for the OpenTools Basic / Advanced Ordernumber for WooCommerce plugin. This extension plugin can provide additional variables, modify existing variables and post-process the generated numbers. + * Description: An extension plugin for the OpenTools Basic / Advanced Ordernumber + * for WooCommerce plugin that adds the number of orders the user has already + * posted in the variable UserOrderCount. * Version: 1.0 * Author: Open Tools * Author URI: http://open-tools.net - * Text Domain: woocommerce-ordernumbers-extension-User_order_count + * Text Domain: woocommerce-ordernumbers-extension-Woocommerce-ordernumber-userordercount * License: GPL2+ * Network: true */ @@ -27,20 +29,11 @@ if ( ! defined( 'ABSPATH' ) ) { * * Returns the new array of variables (even if unmodified!) */ -add_filter('opentools_ordernumber_replacements', "ordernumber_replacements_User_order_count", 10, 3); +add_filter('opentools_ordernumber_replacements', "ordernumber_replacements_userordercount", 10, 3); -ordernumber_replacements_User_order_count($reps, $details, $nrtype) { +function ordernumber_replacements_userordercount($reps, $details, $nrtype) { + // Return the number of orders this user has already posted $userid = $details->get_user_id(); - - // Case 1: Return the number of orders this user has already posted (+1, - // because the current order is not yet registered with WC!) - $reps['[userordercount]'] = wc_get_customer_order_count($userid)+1; - - // Case 2: Add a [Type] variable that holds either "ordernumber" or "invoice" - $reps['[type]'] = $nrtype; - - // Case 3: Modify an existing variable: - $reps['[second]'] = $reps['[second]'] + 15; - + $reps['[userordercount]'] = wc_get_customer_order_count($userid); return $reps; }