Commit 46f67c96 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

Version 1.1: Add min/max value settings

parent e9a1bb02
BASE=donation
PLUGINTYPE=vmcustom
VERSION=1.0.1
VERSION=1.1.0
PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html
......
......@@ -29,17 +29,32 @@ class plgVmCustomDonation extends vmCustomPlugin {
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
$varsToPush = array(
'min_amount'=>array('0.0', 'char'),
'max_amount'=>array('', 'char'),
);
$this->setConfigParameterable('custom_params',$varsToPush);
}
/**
* @see Form displayed in the product edit page in the BE, configure the download file
* @author Reinhold Kainhofer
*/
function plgVmOnProductEdit($field, $product_id, &$row,&$retValue) {
if ($field->custom_element != $this->_name) return '';
$this->parseCustomParams($field);
$html ='
<fieldset>
<legend>'. JText::_('VMCUSTOM_DONATION') .'</legend>
<table class="admintable">
'.VmHTML::row('input','VMCUSTOM_DONATION_MIN','custom_param['.$row.'][min_amount]',$field->min_amount).
VmHTML::row('input','VMCUSTOM_DONATION_MAX','custom_param['.$row.'][max_amount]',$field->max_amount).
'<tr>
</table>
</fieldset>';
$retValue .= $html;
$row++;
return true ;
}
/**
......@@ -125,7 +140,18 @@ class plgVmCustomDonation extends vmCustomPlugin {
public function plgVmCalculateCustomVariant($product, &$productCustomsPrice, $selected){
if ($productCustomsPrice->custom_element !==$this->_name) return ;
$customVariant = $this->getCustomVariant($product, $productCustomsPrice, $selected);
// TODO: Implement bounds for "donation": max/min value.
if (!empty($customVariant['customprice'])) {
if (!empty($productCustomsPrice->min_amount) && ($customVariant['customprice']<$productCustomsPrice->min_amount)) {
$customVariant['customprice'] = $productCustomsPrice->min_amount;
}
if (!empty($productCustomsPrice->max_amount) && ($customVariant['customprice']<$productCustomsPrice->max_amount)) {
$customVariant['customprice'] = $productCustomsPrice->max_amount;
}
// if ($customVariant['customprice']<0) {
// $customVariant['customprice'] = 0;
// }
$productCustomsPrice->custom_price = $customVariant['customprice'];
} else {
$productCustomsPrice->custom_price = 0.0;
......
......@@ -12,6 +12,12 @@
-------------------------------------------------------------------------*/
// no direct access
defined('_JEXEC') or die('Restricted access');
/**
* Installation script for the plugin
*
* @copyright Copyright (C) 2013 Reinhold Kainhofer, office@open-tools.net
* @license GPL v3+, http://www.gnu.org/copyleft/gpl.html
*/
class plgVmCustomDonationInstallerScript
{
......
......@@ -6,7 +6,7 @@
<authorUrl>http://www.open-tools.net/</authorUrl>
<copyright>Copyright (C) 2013 Reinhold Kainhofer. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl.html GNU/GPL v3+</license>
<version>1.0.1</version>
<version>1.1.0</version>
<description>VMCUSTOM_DONATION_DESC</description>
<files>
<filename plugin="donation">donation.php</filename>
......
......@@ -11,7 +11,7 @@
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$class='vmcustom-settext';
$class='vmcustom-settext'; ?>
<input class="<?php echo $class ?>" type="text" value="" size="4" name="customPlugin[<?php echo $viewData[0]->virtuemart_customfield_id ?>][<?php echo $this->_name?>][customprice]"><?php echo CurrencyDisplay::getInstance ()->getSymbol(); ?><br />
<?php
......
......@@ -6,3 +6,7 @@
VMCUSTOM_DONATION="Spenden für VirtueMart"
VMCUSTOM_DONATION_DESC="VirtueMart Benutzerfeld Erweiterung, die Benutzern einen Spendenbetrag zum Produktpreis hinzufügen oder den Preis des Produktes selbst festlegen lässt."
VMCUSTOM_DONATION_MIN="Minimaler Betrag"
VMCUSTOM_DONATION_MIN_TIP="Dies ist der minimale Betrag, der eingegeben werden kann. Kleinere Beträge werden auf diesen Wert gesetzt. Leer lassen (nicht auf 0 setzen!), um keine untere Schranke zu setzen. Auf 0 setzen, um negative Werte zu verhindern (Standardeinstellung)."
VMCUSTOM_DONATION_MAX="Maximaler Betrag"
VMCUSTOM_DONATION_MAX_TIP="Dies ist der maximale Betrag, der eingegeben werden kann. Größere Betrage werden auf diesen Wert gesetzt. Leer lassen (nicht auf 0 setzen!), um keine obere Schranke zu setzen. Auf 0 setzen, um nur negative Werte zu erlauben."
......@@ -6,3 +6,8 @@
VMCUSTOM_DONATION="Donations for VirtueMart"
VMCUSTOM_DONATION_DESC="VirtueMart customfield plugin to let the user add a donation or set the price of a product."
VMCUSTOM_DONATION_MIN="Minimal amount allowed"
VMCUSTOM_DONATION_MIN_TIP="This is the minimum amount that the user is allowed to enter. Values smaller than this value will be reset to this value. Leave this field empty if you don't want to set any lower limit. Set this value to 0 to prohibit negative values (default)."
VMCUSTOM_DONATION_MAX="Maximum amount allowed"
VMCUSTOM_DONATION_MAX_TIP="This is the maximum amount that the user is allowed to enter. Values larger than this value will be reset to this value. Leave this field empty if you don't want to impose any upper limit."
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