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

Version 1.0.0: Initial public release of the rules-based shipping plugin

Implement arithmetic operations, create advanced version
parent 64b351cd
No related branches found
No related tags found
No related merge requests found
Showing
with 167 additions and 0 deletions
*~ *~
language/en-GB/en-GB.plg_vmshipment_rules_shipping_advanced.ini
language/en-GB/en-GB.plg_vmshipment_rules_shipping_advanced.sys.ini
Makefile 0 → 100644
BASE=rules_shipping
BASE_ADV=rules_shipping_advanced
PLUGINTYPE=vmshipment
VERSION=1.0.0
PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html
PLUGINFILES_ADV=$(BASE_ADV).php $(BASE).php $(BASE_ADV).script.php $(BASE_ADV).xml index.html
TRANSLATIONS=$(call wildcard,language/*/*.plg_$(PLUGINTYPE)_$(BASE).*ini)
TRANSLATIONS_ADV=$(subst $(BASE),$(BASE_ADV),$(TRANSLATIONS))
INDEXFILES=language/index.html $(call wildcard,language/**/index.html) $(call wildcard,elements/*.html)
ELEMENTS=$(call wildcard,elements/*.php)
ZIPFILE=plg_$(PLUGINTYPE)_$(BASE)_v$(VERSION).zip
ZIPFILE_ADV=plg_$(PLUGINTYPE)_$(BASE_ADV)_v$(VERSION).zip
ADVANCEDFILES=$(call wildcard,$(BASE)_advanced.*)
all: translations zip
translations: $(TRANSLATIONS)
@echo $(TRANSLATIONS_ADV)
@cp language/en-GB/en-GB.plg_vmshipment_rules_shipping.ini language/en-GB/en-GB.plg_vmshipment_rules_shipping_advanced.ini
@cp language/en-GB/en-GB.plg_vmshipment_rules_shipping.sys.ini language/en-GB/en-GB.plg_vmshipment_rules_shipping_advanced.sys.ini
zip: $(PLUGINFILES) $(TRANSLATIONS) $(ADVANCEDFILES)
@echo "Packing all files into distribution file $(ZIPFILE):"
@zip -r $(ZIPFILE) $(PLUGINFILES) $(TRANSLATIONS) $(ELEMENTS) $(INDEXFILES)
@zip -r $(ZIPFILE_ADV) $(PLUGINFILES_ADV) $(TRANSLATIONS_ADV) $(ELEMENTS) $(INDEXFILES)
clean:
rm -f $(ZIPFILE) $(ZIPFILE_ADV)
<!DOCTYPE html><title></title>
<?php
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
/**
* A label/header element, displayed left-aligned, spanning the whole width. This can be used for section headers as well as for explanatory text
*/
class JElementRKLabel extends JElement
{
/**
* Element name
*
* @access protected
* @var string
*/
var $_name = 'rklabel';
function fetchElement($name, $value, &$node, $control_name)
{
$class = ( $node->attributes('class') ? 'class="'.$node->attributes('class').'"' : 'class="text_area"' );
return '<label for="'.$name.'"'.$class.'>'.JText::_($value).'</label>';
}
/**
* Method to render an xml element
*
* @param string &$xmlElement Name of the element
* @param string $value Value of the element
* @param string $control_name Name of the control
*
* @return array Attributes of an element
*
* @deprecated 12.1
* @since 11.1
*/
public function render(&$xmlElement, $value, $control_name = 'params')
{
// Deprecation warning.
JLog::add('JElement::render is deprecated.', JLog::WARNING, 'deprecated');
$name = $xmlElement->attributes('name');
$label = $xmlElement->attributes('label');
$descr = $xmlElement->attributes('description');
//make sure we have a valid label
$label = $label ? $label : $name;
$result[0] = NULL;
// $result[0] = $this->fetchTooltip($label, $descr, $xmlElement, $control_name, $name);
$result[1] = $this->fetchElement($name, $value, $xmlElement, $control_name);
$result[2] = $descr;
$result[3] = $label;
$result[4] = $value;
$result[5] = $name;
return $result;
}
}
\ No newline at end of file
images/plg_vmshipping_rules_shipping_advanced_icon.png

52 KiB

images/plg_vmshipping_rules_shipping_cart.png

19.6 KiB

images/plg_vmshipping_rules_shipping_cart1.png

16.2 KiB

images/plg_vmshipping_rules_shipping_cart2.png

16.3 KiB

images/plg_vmshipping_rules_shipping_cart3.png

21.5 KiB

images/plg_vmshipping_rules_shipping_config.png

90.3 KiB

images/plg_vmshipping_rules_shipping_config1.png

23.6 KiB

images/plg_vmshipping_rules_shipping_icon.png

50.9 KiB

File added
images/plg_vmshipping_rules_shipping_installation.png

20.1 KiB

; VM2 General Shipping plugin
; Copyright (C) 20123Reinhold Kainhofer. All rights reserved.
; License http://www.gnu.org/licenses/gpl.html GNU/GPL
; Note : All ini files need to be saved as UTF-8 - No BOM
VMSHIPMENT_RULES = "VM2 - Shipping by Rules"
VMSHIPMENT_RULES_DESC = ""
VMSHIPMENT_RULES_ADV = "VM2 - Advanced Shipping by Rules"
VMSHIPMENT_RULES_ADV_DESC = ""
VMSHIPMENT_RULES_PLUGIN="<b>Shipment based on general rules (weight, products, amount) per country-zones</b>"
VMSHIPMENT_RULES_PLUGIN_ADV="<b>Shipment based on general rules (weight, products, amount) per country-zones, including arithmetic expression</b>"
VMSHIPMENT_RULES_HELP="<div style='background: #DDDDDD; padding:5px; margin:3px;'><h2>Overview of the Rules Syntax</h2>
<ul><li>Each line contains one rule consisting of several <b>conditions and assignments in arbitrary order and separated by semicolons</b>. </li>
<li>The <b>first matching rule is used</b> to calculate the shipping costs.</li>
<li>All rule parts with <b>comparison operators (&lt;, &lt;=, =&lt;, ==, !=, &lt;&gt;, &gt;=, =&gt;, &gt;)</b> are conditions.</li>
<li> Supported <b>variables (case-insensitive)</b>: <b><tt>Amount</tt></b>, <b><tt>Weight</tt></b>, <b><tt>ZIP</tt></b>, <b><tt>Products</tt></b> (number of different products order), <b><tt>Articles</tt></b> (each product counted with its quantity).</li>
<li>A condition can consist of multiple chained comparisons.</li>
<li>All rule parts of the form <b><tt>[VARIABLE]=VALUE</tt> are assignments</b>, with <tt>[VARIABLE]</tt> being one of <b><tt>Name</tt></b> (optional name of the rule, displayed in the cart and invoice), <b><tt>Shipping</tt></b> (shipping cost if the rule matches). The <tt>Shipping=</tt> can be left out. I.e. a rule part consisting only of a numerical value is understood as shipping cost.</li>
</ul>
<p>EXAMPLE: A rule named &quot;Europe&quot; that sets shipping costs of 4.50 for order amounts from 50 to less than 100, and free shipping from 100€ on would be:</p><blockquote><tt>Name=Europe; 50&lt;=Amount&lt;100; Shipping=4.50<br>Name=Free Shipping; 100&lt;= Amount; 0</tt></blockquote>
</div>"
VMSHIPMENT_RULES_HELP_ADV="<div style='background: #DDDDDD; padding:5px; margin:3px;'><h2>Overview of the Rules Syntax</h2>
<ul><li>Each line contains one rule consisting of several <b>conditions and assignments in arbitrary order and separated by semicolons</b>. </li>
<li>The <b>first matching rule is used</b> to calculate the shipping costs.</li>
<li>All rule parts with <b>comparison operators (&lt;, &lt;=, =&lt;, ==, !=, &lt;&gt;, &gt;=, =&gt;, &gt;)</b> are conditions.</li>
<li> Supported <b>variables (case-insensitive)</b>: <b><tt>Amount</tt></b>, <b><tt>Weight</tt></b>, <b><tt>ZIP</tt></b>, <b><tt>Products</tt></b> (number of different products order), <b><tt>Articles</tt></b> (each product counted with its quantity).</li>
<li>A condition can consist of multiple chained comparisons.</li>
<li>All rule parts of the form <b><tt>[VARIABLE]=VALUE</tt> are assignments</b>, with <tt>[VARIABLE]</tt> being one of <b><tt>Name</tt></b> (optional name of the rule, displayed in the cart and invoice), <b><tt>Shipping</tt></b> (shipping cost if the rule matches). The <tt>Shipping=</tt> can be left out. I.e. a rule part consisting only of a numerical value is understood as shipping cost.</li>
<li>In the advanced version, all expressions (conditions and shipping costs) may contain <b>arbitrary basic arithmetic expressions (+, -, *, /, %, ^ and parentheses)</b> of the above variables.</li>
</ul>
<p>EXAMPLE: A rule named &quot;Europe&quot; that sets shipping costs of 5€ plus 1.50€ per article for order amounts from 50 to less than 100, and free shipping from 100€ on would be:</p><blockquote><tt>Name=Europe; 50&lt;=Amount&lt;100; Shipping=5+1.50*Articles<br>Name=Free Shipping; 100&lt;= Amount; 0</blockquote>
</div>"
VMSHIPMENT_RULES_COUNTRIES1_LABEL="<b>Rules for country set 1</b>"
VMSHIPMENT_RULES_COUNTRIES2_LABEL="<b>Rules for country set 2</b>"
VMSHIPMENT_RULES_COUNTRIES3_LABEL="<b>Rules for country set 3</b>"
VMSHIPMENT_RULES_COUNTRIES4_LABEL="<b>Rules for country set 4</b>"
VMSHIPMENT_RULES_COUNTRIES5_LABEL="<b>Rules for country set 5</b>"
VMSHIPMENT_RULES_COUNTRIES6_LABEL="<b>Rules for country set 6</b>"
VMSHIPMENT_RULES_COUNTRIES7_LABEL="<b>Rules for country set 7</b>"
VMSHIPMENT_RULES_COUNTRIES8_LABEL="<b>Rules for country set 8</b>"
VMSHIPMENT_RULES_COUNTRIES="Countries"
VMSHIPMENT_RULES_COUNTRIES_DESC="Select the countries to which the following rules should be restricted. If left empty, the rules will apply to all countries."
VMSHIPMENT_RULES_TAX="Tax"
VMSHIPMENT_RULES_TAX_DESC="Tax methods applied to the shipping cost if any of the given rules matches."
VMSHIPMENT_RULES_RULES="Rules"
VMSHIPMENT_RULES_RULES_DESC=""
VMSHIPMENT_RULES_SHIPPING_NAME="Shipment Name"
VMSHIPMENT_RULES_WEIGHT="Order Weight"
VMSHIPMENT_RULES_ARTICLES="Articles/Products in Order"
VMSHIPMENT_RULES_COST="Shipment Cost"
VMSHIPMENT_RULES_UNKNOWN_VARIABLE="Unknown variable '%s' in rule '%s'"
VMSHIPMENT_RULES_UNKNOWN_OPERATOR="Unknown operator '%s' in shipment rule '%s'"
VMSHIPMENT_RULES_PARSE_MISSING_PAREN="Error during parsing expression '%s': Opening parenthesis cannot be found!"
VMSHIPMENT_RULES_PARSE_PAREN_NOT_CLOSED="Error during parsing expression '%s': A parenthesis was not closed properly!"
VMSHIPMENT_RULES_EVALUATE_NONNUMERIC="Encountered term '%s' during evaluation, that does not evaluate to a numeric value! (Full rule: '%s')"
VMSHIPMENT_RULES_EVALUATE_SYNTAXERROR="Syntax error during evaluation, RPN is not well formed! (Full rule: '%s')"
VMSHIPMENT_RULES_EVALUATE_UNKNOWN_OPERATOR="Unknown operator '%s' encountered during evaluation of rule '%s'."
VMSHIPMENT_RULES_EVALUATE_UNKNOWN_ERROR="Unknown error occurred during evaluation of rule '%s'."
\ No newline at end of file
; VM2 Rule-based Shipping plugin
; Copyright (C) 20123Reinhold Kainhofer. All rights reserved.
; License http://www.gnu.org/licenses/gpl.html GNU/GPL
; Note : All ini files need to be saved as UTF-8 - No BOM
VMSHIPMENT_RULES = "VM2 - Shipping by Rules"
VMSHIPMENT_RULES_DESC = ""
VMSHIPMENT_RULES_ADV = "VM2 - Advanced Shipping by Rules"
VMSHIPMENT_RULES_ADV_DESC = ""
<!DOCTYPE html><title></title>
<!DOCTYPE html><title></title>
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment