Skip to content
Snippets Groups Projects
Commit 7e8de8be authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

V4.0.1: Add onVmOrdernumberPostprocessNumber trigger to postprocess the...

V4.0.1: Add onVmOrdernumberPostprocessNumber trigger to postprocess the numbers, e.g. to append a checksum or store the number in some external system, too
parent 0a856e10
Branches
Tags V4.0.1
No related merge requests found
BASE=ordernumber BASE=ordernumber
PLUGINTYPE=vmshopper PLUGINTYPE=vmshopper
VERSION=4.0 VERSION=4.0.1
PLUGINFILES=$(BASE).php ordernumber_helper_joomla.php $(BASE).script.php $(BASE).xml index.html library/ PLUGINFILES=$(BASE).php ordernumber_helper_joomla.php $(BASE).script.php $(BASE).xml index.html library/
......
...@@ -210,6 +210,8 @@ class plgVmShopperOrdernumber extends vmShopperPlugin { ...@@ -210,6 +210,8 @@ class plgVmShopperOrdernumber extends vmShopperPlugin {
); );
$customvars = $this->helper->transposeCustomVariables($this->params->get ('replacements', array())); $customvars = $this->helper->transposeCustomVariables($this->params->get ('replacements', array()));
$number = $this->helper->createNumber ($fmt, $type, $order, $customvars, $ctrsettings); $number = $this->helper->createNumber ($fmt, $type, $order, $customvars, $ctrsettings);
JPluginHelper::importPlugin('vmshopper');
JDispatcher::getInstance()->trigger('onVmOrdernumberPostprocessNumber',array(&$number, $type, $order));
return $number; return $number;
} else { } else {
return false; return false;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<authorUrl>http://www.open-tools.net/</authorUrl> <authorUrl>http://www.open-tools.net/</authorUrl>
<copyright>Copyright (C) 2012-2015 Reinhold Kainhofer. All rights reserved.</copyright> <copyright>Copyright (C) 2012-2015 Reinhold Kainhofer. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3</license> <license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3</license>
<version>4.0</version> <version>4.0.1</version>
<releaseDate>2015-05-23</releaseDate> <releaseDate>2015-05-23</releaseDate>
<releaseType>Minor update</releaseType> <releaseType>Minor update</releaseType>
<downloadUrl>http://open-tools.net/virtuemart/advanced-ordernumbers.html</downloadUrl> <downloadUrl>http://open-tools.net/virtuemart/advanced-ordernumbers.html</downloadUrl>
......
BASE=ordernumber_checksum
PLUGINTYPE=vmshopper
ZIPBASE=opentools_vmshopper
VERSION=1.0
PLUGINFILES=$(BASE).php $(BASE).xml index.html
ZIPFILE=plg_$(ZIPBASE)_$(BASE)_v$(VERSION).zip
all: zip
zip: $(PLUGINFILES) $(ADVANCEDFILES)
@echo "Packing all files into distribution file $(ZIPFILE):"
@zip -r $(ZIPFILE) $(PLUGINFILES)
clean:
rm -f $(ZIPFILE)
<?php
defined ('_JEXEC') or die('Restricted access');
/**
* Plugin providing checksums for the VM Ordernumber plugin
*
* @copyright Copyright (C) 2016 Reinhold Kainhofer, office@open-tools.net
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*
* http://open-tools.net/
*
*/
if (!class_exists('vmShopperPlugin'))
require(JPATH_VM_PLUGINS . DS . 'vmshopperplugin.php');
/** Extension plugin for the Ordernumber plugin for VirtueMart
*/
class plgVmShopperOrdernumber_checksum extends VmShopperPlugin {
// Unfortunately, this dummy function needs to be implementd, because it's abstract in the parent class!
public function plgVmOnUpdateOrderBEShopper($_orderID) {}
/** Trigger to postprocess generated numbers (e.g. to add checksums or call
* external bookkeeping systems to store an invoice number).
* The number can be changed by simply assigning a new value to $number.
*
* Possible values for $type are "ordernumber", "invoice_number", "customer_number", etc.
*/
function onVmOrdernumberPostprocessNumber(&$number, $type, $order) {
// Example: Append the length of the number to the number
error_log("Called onVmOrdernumberPostprocessNumber with number $number and type $type");
if ($type=="order_number") {
$checksum = strlen($number);
$number .= $checksum;
}
}
}
// No closing tag
<?xml version="1.0" encoding="UTF-8" ?>
<extension version="2.5" type="plugin" group="vmshopper" method="upgrade">
<name>VM Advanced Ordernumbers - Append Checksum</name>
<creationDate>2016-04-27</creationDate>
<author>Reinhold Kainhofer, Open Tools</author>
<authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2016, Reinhold Kainhofer</copyright>
<license>GPL v3+</license>
<version>1.0</version>
<description>Appends a customized checksum to order numbers generated by the Advanced Ordernumbers plugin for VirtueMart.</description>
<files>
<filename plugin="ordernumber_checksum">ordernumber_checksum.php</filename>
</files>
<!-- Joomla 2.x and 3.x support (fields rather than params): -->
<config></config>
</extension>
File added
...@@ -23,6 +23,7 @@ if (!class_exists('vmShopperPlugin')) ...@@ -23,6 +23,7 @@ if (!class_exists('vmShopperPlugin'))
class plgVmShopperYOUR_PLUGIN_NAME extends VmShopperPlugin { class plgVmShopperYOUR_PLUGIN_NAME extends VmShopperPlugin {
// Unfortunately, this dummy function needs to be implementd, because it's abstract in the parent class! // Unfortunately, this dummy function needs to be implementd, because it's abstract in the parent class!
public function plgVmOnUpdateOrderBEShopper($_orderID) {} public function plgVmOnUpdateOrderBEShopper($_orderID) {}
/** Trigger to add variables to be used in the number formats /** Trigger to add variables to be used in the number formats
* You can add new variables to the $cartvals array or modify existing ones. They will be directly * You can add new variables to the $cartvals array or modify existing ones. They will be directly
* available in all formats. This trigger will be called whenever the ordernumber plugin creates a * available in all formats. This trigger will be called whenever the ordernumber plugin creates a
...@@ -44,6 +45,26 @@ class plgVmShopperYOUR_PLUGIN_NAME extends VmShopperPlugin { ...@@ -44,6 +45,26 @@ class plgVmShopperYOUR_PLUGIN_NAME extends VmShopperPlugin {
// You can also modify existing variables: // You can also modify existing variables:
$reps['[second]'] = $reps['[second]'] + 15; $reps['[second]'] = $reps['[second]'] + 15;
} }
/** Trigger to postprocess generated numbers (e.g. to add checksums or call
* external bookkeeping systems to store an invoice number).
* The number can be changed by simply assigning a new value to $number.
*
* Possible values for $type are "order_number", "order_password", "invoice_number", "customer_number", etc.
*/
function onVmOrdernumberPostprocessNumber(&$number, $type, $order) {
// Example: Append the length of the number to the number
if ($type=="order_number") {
$checksum=strlen($number);
$number .= $checksum;
}
// Example 2: Store the invoice number in an external bookkeeping system
if ($type=="invoice_number") {
// simply take $number and trigger a webservice call sending that value
// (and e.g. the order ID stored in the $order object) to the bookkeeping system
}
}
} }
// No closing tag // No closing tag
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment