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

When NoShipping is used, print rule Name as error message to inform the user.

Special care is taken (using a global array of messages...) to ensure that the message is not printed twice...
parent 2dc548cd
No related branches found
No related tags found
No related merge requests found
...@@ -56,3 +56,5 @@ VMSHIPMENT_RULES_EVALUATE_UNKNOWN_VALUE="Evaluation yields unknown value while e ...@@ -56,3 +56,5 @@ VMSHIPMENT_RULES_EVALUATE_UNKNOWN_VALUE="Evaluation yields unknown value while e
VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_ARGS="List function '%s' requires all arguments to be lists. (Full rule: '%s')" VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_ARGS="List function '%s' requires all arguments to be lists. (Full rule: '%s')"
VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN="Unknown list function '%s' encountered. (Full rule: '%s')" VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN="Unknown list function '%s' encountered. (Full rule: '%s')"
VMSHIPMENT_RULES_NOSHIPPING_MESSAGE="%s"
...@@ -29,6 +29,9 @@ if (class_exists ('plgVmShipmentRules_Shipping_Base')) { ...@@ -29,6 +29,9 @@ if (class_exists ('plgVmShipmentRules_Shipping_Base')) {
return; return;
} }
// Keep track of warning messages, so we don't print them twice:
$printed_warnings = array();
/** Shipping costs according to general rules. /** Shipping costs according to general rules.
* Supported Variables: Weight, ZIP, Amount, Products (1 for each product, even if multiple ordered), Articles * Supported Variables: Weight, ZIP, Amount, Products (1 for each product, even if multiple ordered), Articles
* Assignable variables: Shipping, Name * Assignable variables: Shipping, Name
...@@ -58,6 +61,16 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { ...@@ -58,6 +61,16 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin {
public function getVmPluginCreateTableSQL () { public function getVmPluginCreateTableSQL () {
return $this->createTableSQL ('Shipment Rules Table'); return $this->createTableSQL ('Shipment Rules Table');
} }
public function printWarning($message) {
global $printed_warnings;
// JFactory::getApplication()->enqueueMessage("<pre>warnings so far are:".print_r($printed_warnings,1). ", new warning: |$message|</pre>", 'warning');
if (!in_array($message, $printed_warnings)) {
JFactory::getApplication()->enqueueMessage($message, 'error');
$printed_warnings[] = $message;
}
}
/** /**
* @return array * @return array
...@@ -534,6 +547,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { ...@@ -534,6 +547,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin {
$method->rule_name = $r->getRuleName($cartvals); $method->rule_name = $r->getRuleName($cartvals);
// If NoShipping is set, this method should NOT offer any shipping at all, so return FALSE, otherwise TRUE // If NoShipping is set, this method should NOT offer any shipping at all, so return FALSE, otherwise TRUE
if ($r->isNoShipping()) { if ($r->isNoShipping()) {
$this->printWarning(JText::sprintf('VMSHIPMENT_RULES_NOSHIPPING_MESSAGE', $method->rule_name));
vmdebug('checkConditions '.$method->shipment_name.' indicates NoShipping for rule "'.$method->rule_name.'" ('.$r->rulestring.').'); vmdebug('checkConditions '.$method->shipment_name.' indicates NoShipping for rule "'.$method->rule_name.'" ('.$r->rulestring.').');
return FALSE; return FALSE;
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment