Commit 9cb07ef8 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

Finish extension template; implement UserOrderCount variable

parent 46c54eda
......@@ -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)
......
<?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;
......
=== 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
......
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)
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)
=== 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
......
<?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;
}
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