Commit 95399dca authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

V1.4: When lower bound is given, automatically initialize the product price with that bound

parent 70d48de2
BASE=nametheprice
PLUGINTYPE=vmcustom
VERSION=1.3
FILEBASE=opentools_vm2
VERSION=1.4
FILEBASE=opentools_vm
PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html
......
......@@ -6,7 +6,7 @@
<authorUrl>http://www.open-tools.net/</authorUrl>
<copyright>Copyright (C) 2013-2014 Reinhold Kainhofer. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl.html GNU/GPL v3+</license>
<version>1.3</version>
<version>1.4</version>
<description>VMCUSTOM_NAMETHEPRICE_DESC</description>
<files>
<filename plugin="nametheprice">nametheprice.php</filename>
......
......@@ -19,8 +19,7 @@ if (!defined('VM_VERSION') or VM_VERSION < 3) { // VM2:
$name = 'customProductData['.$field->virtuemart_product_id.']['.$field->virtuemart_custom_id.']['.$field->virtuemart_customfield_id .'][customprice]';
}
?>
<input class="<?php echo $class ?>" type="text" value="" size="6" name="<?php echo $name?>"><?php echo CurrencyDisplay::getInstance ()->getSymbol(); ?><br />
<input class="<?php echo $class ?>" type="text" value="<?php if (is_numeric($field->min_amount) and $field->min_amount>0) echo $field->min_amount; ?>" size="6" name="<?php echo $name?>"><?php echo CurrencyDisplay::getInstance ()->getSymbol(); ?><br />
<?php
// preventing 2 x load javascript
static $namethepricejs;
......@@ -30,15 +29,23 @@ if (!defined('VM_VERSION') or VM_VERSION < 3) { // VM2:
//javascript to update price
$script = '
/* <![CDATA[ */
var namethepricefunc = function($) {
var namethepricefunction = function(formProduct) {
virtuemart_product_id = formProduct.find(\'input[name="virtuemart_product_id[]"]\').val();
Virtuemart.setproducttype(formProduct,virtuemart_product_id);
};
var registernamethepricefunc = function($) {
jQuery(".vmcustom-nametheprice").keyup(function() {
formProduct = $(this).parents("form.product");
virtuemart_product_id = formProduct.find(\'input[name="virtuemart_product_id[]"]\').val();
Virtuemart.setproducttype(formProduct,virtuemart_product_id);
});
formProduct = $(this).parents("form.product");
namethepricefunction(formProduct);
});
};
jQuery("body").on("updateVirtueMartProductDetail", namethepricefunc);
jQuery(document).ready(namethepricefunc);
jQuery("body").on("updateVirtueMartProductDetail", registernamethepricefunc);
jQuery(document).ready(registernamethepricefunc);
jQuery(document).ready(function() {
jQuery(document).find("form.product").each(function() {
namethepricefunction(jQuery(this));
});
});
/* ]]> */
';
$document = JFactory::getDocument()->addScriptDeclaration($script);
......
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