Commit 836210f3 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

Renamed to "Name the Price for VM"; Update to J3/VM3; Properly implement...

Renamed to "Name the Price for VM"; Update to J3/VM3; Properly implement warnings for upper/lower bounds
parent 46f67c96
BASE=donation
BASE=nametheprice
PLUGINTYPE=vmcustom
VERSION=1.1.0
VERSION=1.2
FILEBASE=opentools_vm2
PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html
......@@ -8,7 +9,7 @@ TRANSLATIONS=$(call wildcard,language/*/*.plg_$(PLUGINTYPE)_$(BASE).*ini)
INDEXFILES=language/index.html $(call wildcard,language/*/index.html)
TMPLFILES=$(call wildcard,$(BASE)/tmpl/*.php) $(call wildcard,$(BASE)/tmpl/index.html) $(call wildcard,$(BASE)/index.html)
ASSETS=
ZIPFILE=plg_$(PLUGINTYPE)_$(BASE)_v$(VERSION).zip
ZIPFILE=plg_$(FILEBASE)_$(BASE)_v$(VERSION).zip
zip: $(PLUGINFILES) $(TRANSLATIONS) $(ELEMENTS) $(INDEXFILES) $(TMPLFILES) $(ASSETS)
......
; Virtuemart! Project
; Copyright (C) 2011 Virtuemart Team. All rights reserved.
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
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."
; Virtuemart! Project
; Copyright (C) 2011 Virtuemart Team. All rights reserved.
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
VMCUSTOM_NAMETHEPRICE="Nenn den Preis für VirtueMart"
VMCUSTOM_NAMETHEPRICE_DESC="VirtueMart Benutzerfeld Erweiterung, die Benutzern den Preis des Produktes selbst festlegen lässt (z.B. für Spenden oder Gutscheine)"
VMCUSTOM_NAMETHEPRICE_MIN="Minimaler Betrag"
VMCUSTOM_NAMETHEPRICE_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_NAMETHEPRICE_MAX="Maximaler Betrag"
VMCUSTOM_NAMETHEPRICE_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."
VMCUSTOM_NAMETHEPRICE_ERROR_MAX_EXCEEDED="Der angegebene Wert %d übersteigt das erlaubte Maximum, es wird stattdessen das Maximum %d benutzt.";
VMCUSTOM_NAMETHEPRICE_ERROR_MIN_EXCEEDED="Der angegebene Wert %d unterschreitet das erlaubte Minimum, es wird stattdessen das Minimum %d benutzt.";
......@@ -3,5 +3,5 @@
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
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_NAMETHEPRICE="Nenn den Preis für VirtueMart"
VMCUSTOM_NAMETHEPRICE_DESC="VirtueMart Benutzerfeld Erweiterung, die Benutzern den Preis des Produktes selbst festlegen lässt (z.B. für Spenden oder Gutscheine)"
; Virtuemart! Project
; Copyright (C) 2011 Virtuemart Team. All rights reserved.
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
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."
; Virtuemart! Project
; Copyright (C) 2011 Virtuemart Team. All rights reserved.
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
VMCUSTOM_NAMETHEPRICE="Name Your Price Plugin for VirtueMart"
VMCUSTOM_NAMETHEPRICE_DESC="VirtueMart customfield plugin to let the user determine the price of a product (e.g. for donations or vouchers)."
VMCUSTOM_NAMETHEPRICE_MIN="Minimal amount allowed"
VMCUSTOM_NAMETHEPRICE_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_NAMETHEPRICE_MAX="Maximum amount allowed"
VMCUSTOM_NAMETHEPRICE_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."
VMCUSTOM_NAMETHEPRICE_ERROR_MAX_EXCEEDED="The value %d you entered is larger than the largest allowed value, using the maximum value %d instead.";
VMCUSTOM_NAMETHEPRICE_ERROR_MIN_EXCEEDED="The value %d you entered is smaller than the lowest allowed value, using the minimum value %d instead.";
......@@ -3,5 +3,5 @@
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
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_NAMETHEPRICE="Name Your Price Plugin for VirtueMart"
VMCUSTOM_NAMETHEPRICE_DESC="VirtueMart customfield plugin to let the user determine the price of a product (e.g. for donations or vouchers)."
<?php
/**------------------------------------------------------------------------
# donation.php - VirtueMart 2 plugin for donations
# nametheprice.php - VirtueMart 2 plugin to let customers give the price they want to pay (e.g. for donations or vouchers)
# ------------------------------------------------------------------------
# @author Reinhold Kainhofer, The Open Tools Association
# @copyright Copyright (C) 2013 Reinhold Kainhofer, open-tools.net. All Rights Reserved.
......@@ -16,15 +16,12 @@ defined('_JEXEC') or die( 'Direct Access to ' . basename( __FILE__ ) . ' is not
if (!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
// if(!class_exists('VmTable'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmtable.php');
if (JVM_VERSION === 2) {
if (!defined('VMDONATION_PLUGINPATH')) define('VMDONATION_PLUGINPATH', JPATH_SITE.DS.'plugins'.DS.'vmcustom'.DS.'donation');
if (!defined('VMDONATION_PLUGINWEBROOT')) define('VMDONATION_PLUGINWEBROOT', 'plugins/vmcustom/donation');
} else {
if (!defined('VMDONATION_PLUGINPATH')) define('VMDONATION_PLUGINPATH', JPATH_SITE.DS.'plugins'.DS.'vmcustom');
if (!defined('VMDONATION_PLUGINWEBROOT')) define('VMDONATION_PLUGINWEBROOT', 'plugins/vmcustom');
}
if (!defined('VMNAMETHEPRICE_PLUGINPATH'))
define ('VMNAMETHEPRICE_PLUGINPATH', JPATH_SITE.DS.'plugins'.DS.'vmcustom'.DS.'nametheprice');
if (!defined('VMNAMETHEPRICE_PLUGINWEBROOT'))
define ('VMNAMETHEPRICE_PLUGINWEBROOT', 'plugins/vmcustom/nametheprice');
class plgVmCustomDonation extends vmCustomPlugin {
class plgVmCustomNameThePrice extends vmCustomPlugin {
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
......@@ -32,7 +29,11 @@ class plgVmCustomDonation extends vmCustomPlugin {
'min_amount'=>array('0.0', 'char'),
'max_amount'=>array('', 'char'),
);
$this->setConfigParameterable('custom_params',$varsToPush);
if(!defined('VM_VERSION') or VM_VERSION < 3){
$this->setConfigParameterable('custom_params', $varsToPush);
} else {
$this->setConfigParameterable('customfield_params', $varsToPush);
}
}
/**
......@@ -42,13 +43,18 @@ class plgVmCustomDonation extends vmCustomPlugin {
function plgVmOnProductEdit($field, $product_id, &$row,&$retValue) {
if ($field->custom_element != $this->_name) return '';
$this->parseCustomParams($field);
if (!defined('VM_VERSION') or VM_VERSION < 3) {
$this->parseCustomParams ($field); // Not needed in VM3!
$paramName = 'custom_param';
} else {
$paramName = 'customfield_params';
}
$html ='
<fieldset>
<legend>'. JText::_('VMCUSTOM_DONATION') .'</legend>
<legend>'. JText::_('VMCUSTOM_NAMETHEPRICE') .'</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).
'.VmHTML::row('input','VMCUSTOM_NAMETHEPRICE_MIN', $paramName.'['.$row.'][min_amount]',$field->min_amount).
VmHTML::row('input','VMCUSTOM_NAMETHEPRICE_MAX', $paramName.'['.$row.'][max_amount]',$field->max_amount).
'<tr>
</table>
</fieldset>';
......@@ -57,34 +63,31 @@ class plgVmCustomDonation extends vmCustomPlugin {
return true ;
}
/**
* plgVmOnDisplayProductVariantFE ... Called for product variant custom fields to display on the product details page
*/
function plgVmOnDisplayProductVariantFE($field,&$row,&$group) {
// VM3
function plgVmOnDisplayProductFEVM3(&$product, &$field) {
if ($field->custom_element != $this->_name) return '';
$field->display .= $this->renderByLayout('default',array($field) );
return true;
}
// VM2 legacy
function plgVmOnDisplayProductVariantFE($field,&$idx,&$group) {
// default return if it's not this plugin
if ($field->custom_element != $this->_name) return '';
$this->getCustomParams($field);
$group->display .= $this->renderByLayout('default',array($field,&$idx,&$group ) );
$group->display .= $this->renderByLayout('default',array($field ) );
return true;
}
/**
* @see components/com_virtuemart/helpers/vmCustomPlugin::plgVmOnViewCartModule()
* @author Patrick Kohl
*/
function plgVmOnViewCartModule( $product,$row,&$html) {
return $this->plgVmOnViewCart($product,$row,$html);
}
/**
* @see components/com_virtuemart/helpers/vmCustomPlugin::plgVmOnViewCart()
* @author Patrick Kohl
*/
// VM2 legacy
function plgVmOnViewCart($product,$row,&$html) {
if (empty($product->productCustom->custom_element) or $product->productCustom->custom_element != $this->_name) return '';
if (!$plgParam = $this->GetPluginInCart($product)) return '' ;
foreach($plgParam as $k => $item){
if(!empty($item['customprice']) && ($product->productCustom->virtuemart_customfield_id==$k)){
$currency = CurrencyDisplay::getInstance ();
$html .='<span>'.JText::_($product->productCustom->custom_title).' '.$currency->priceDisplay($item['customprice']).'</span>';
......@@ -93,39 +96,65 @@ class plgVmCustomDonation extends vmCustomPlugin {
return true;
}
function plgVmOnViewCartVM3(&$product, &$productCustom, &$html) {
if (empty($productCustom->custom_element) or $productCustom->custom_element != $this->_name) return false;
/**
* vendor order display BE
*/
function plgVmDisplayInOrderBE($item, $row, &$html) {
if (empty($item->productCustom->custom_element) or $item->productCustom->custom_element != $this->_name) return '';
$this->plgVmOnViewCart($item,$row,$html); //same render as cart
if(empty($product->customProductData[$productCustom->virtuemart_custom_id][$productCustom->virtuemart_customfield_id])) return false;
$item = $product->customProductData[$productCustom->virtuemart_custom_id][$productCustom->virtuemart_customfield_id];
if(isset($item['customprice'])){
$currency = CurrencyDisplay::getInstance ();
$html .='<span>'.vmText::_($productCustom->custom_title).' '.$currency->priceDisplay($item['customprice']).'</span>';
}
return true;
}
/**
*
* shopper order display FE
*/
function plgVmOnViewCartModuleVM3( &$product, &$productCustom, &$html) {
return $this->plgVmOnViewCartVM3($product,$productCustom,$html);
}
function plgVmDisplayInOrderBEVM3( &$product, &$productCustom, &$html) {
$this->plgVmOnViewCartVM3($product,$productCustom,$html);
}
function plgVmDisplayInOrderFEVM3( &$product, &$productCustom, &$html) {
$this->plgVmOnViewCartVM3($product,$productCustom,$html);
}
function plgVmOnViewCartModule($product,$row,&$html) {
return $this->plgVmOnViewCart($product,$row,$html);
}
function plgVmDisplayInOrderBE($item, $row, &$html) {
return $this->plgVmOnViewCart($item,$row,$html); //same render as cart
}
function plgVmDisplayInOrderFE($item, $row, &$html) {
if (empty($item->productCustom->custom_element) or $item->productCustom->custom_element != $this->_name) return '';
$this->plgVmOnViewCart($item,$row,$html); //same render as cart
return $this->plgVmOnViewCart($item,$row,$html); //same render as cart
}
/**
* We must reimplement this triggers for joomla 1.7
* vmplugin triggers note by Max Milbers
*/
public function plgVmOnStoreInstallPluginTable($psType, $name) {
public function plgVmOnStoreInstallPluginTable($psType) {
//Should the textinput use an own internal variable or store it in the params?
//Here is no getVmPluginCreateTableSQL defined
// return $this->onStoreInstallPluginTable($psType);
}
// VM2 legacy
function plgVmDeclarePluginParamsCustom($psType,$name,$id, &$data){
return $this->declarePluginParams('custom', $name, $id, $data);
}
// VM3
function plgVmDeclarePluginParamsCustomVM3 (&$data) {
return $this->declarePluginParams ('custom', $data);
}
function plgVmGetTablePluginParams($psType, $name, $id, &$xParams, &$varsToPush){
return $this->getTablePluginParams($psType, $name, $id, $xParams, $varsToPush);
}
function plgVmSetOnTablePluginParamsCustom($name, $id, &$table){
return $this->setOnTablePluginParams($name, $id, $table);
}
......@@ -137,21 +166,23 @@ class plgVmCustomDonation extends vmCustomPlugin {
return $this->onDisplayEditBECustom($virtuemart_custom_id,$customPlugin);
}
// VM2 legacy
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.
// bounds for "nametheprice": max/min value.
if (!empty($customVariant['customprice'])) {
// Error handling to display errors to the user, e.g. when the amount exceeds the min/max values
// This does not yet work for the AJAX calls, because in VM2 the json can only contain the prices
if (!empty($productCustomsPrice->min_amount) && ($customVariant['customprice']<$productCustomsPrice->min_amount)) {
JFactory::getApplication()->enqueueMessage(JText::sprintf('VMCUSTOM_NAMETHEPRICE_ERROR_MIN_EXCEEDED', $selected['customprice'], $customfield->min_amount), 'warning');
$customVariant['customprice'] = $productCustomsPrice->min_amount;
}
if (!empty($productCustomsPrice->max_amount) && ($customVariant['customprice']<$productCustomsPrice->max_amount)) {
if (!empty($productCustomsPrice->max_amount) && ($customVariant['customprice']>$productCustomsPrice->max_amount)) {
JFactory::getApplication()->enqueueMessage(JText::sprintf('VMCUSTOM_NAMETHEPRICE_ERROR_MAX_EXCEEDED', $selected['customprice'], $customfield->max_amount), 'warning');
$customVariant['customprice'] = $productCustomsPrice->max_amount;
}
// if ($customVariant['customprice']<0) {
// $customVariant['customprice'] = 0;
// }
$productCustomsPrice->custom_price = $customVariant['customprice'];
} else {
$productCustomsPrice->custom_price = 0.0;
......@@ -159,6 +190,30 @@ class plgVmCustomDonation extends vmCustomPlugin {
return true;
}
// VM3
public function plgVmPrepareCartProduct(&$product, &$customfield, $selected, &$modificatorSum){
if ($customfield->custom_element !==$this->_name) return ;
if (!empty($selected['customprice'])) {
// Error handling to display errors to the user, e.g. when the amount exceeds the min/max values
if (!empty($customfield->min_amount) && ($selected['customprice']<$customfield->min_amount)) {
JFactory::getApplication()->enqueueMessage(JText::sprintf('VMCUSTOM_NAMETHEPRICE_ERROR_MIN_EXCEEDED', $selected['customprice'], $customfield->min_amount), 'warning');
$selected['customprice'] = $customfield->min_amount;
}
if (!empty($customfield->max_amount) && ($selected['customprice']>$customfield->max_amount)) {
JFactory::getApplication()->enqueueMessage(JText::sprintf('VMCUSTOM_NAMETHEPRICE_ERROR_MAX_EXCEEDED', $selected['customprice'], $customfield->max_amount), 'warning');
$selected['customprice'] = $customfield->max_amount;
}
$modificatorSum += $selected['customprice'];
} else {
$modificatorSum += 0.0;
}
return true;
}
public function plgVmDisplayInOrderCustom(&$html,$item, $param,$productCustom, $row ,$view='FE'){
$this->plgVmDisplayInOrderCustom($html,$item, $param,$productCustom, $row ,$view);
}
......
<?php
/**------------------------------------------------------------------------
# donation.script.php - VirtueMart 2 plugin for donations, installation script
# donation.script.php - VirtueMart 2 and 3 plugin to let customers determine the price of a product, installation script
# ------------------------------------------------------------------------
# @author Reinhold Kainhofer, The Open Tools Association
# @copyright Copyright (C) 2013 Reinhold Kainhofer, open-tools.net. All Rights Reserved.
# @copyright Copyright (C) 2013-2014 Reinhold Kainhofer, open-tools.net. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl.html GNU/GPL
* @package VirtueMart
* @subpackage vmcustom
......@@ -15,11 +15,11 @@ defined('_JEXEC') or die('Restricted access');
/**
* Installation script for the plugin
*
* @copyright Copyright (C) 2013 Reinhold Kainhofer, office@open-tools.net
* @copyright Copyright (C) 2013-2014 Reinhold Kainhofer, office@open-tools.net
* @license GPL v3+, http://www.gnu.org/copyleft/gpl.html
*/
class plgVmCustomDonationInstallerScript
class plgVmCustomNameThePriceInstallerScript
{
/**
* Constructor
......@@ -59,7 +59,7 @@ class plgVmCustomDonationInstallerScript
{
// enabling plugin
$db =& JFactory::getDBO();
$db->setQuery('update #__extensions set enabled = 1 where type = "plugin" and element = "donation" and folder = "vmcustom"');
$db->setQuery('update #__extensions set enabled = 1 where type = "plugin" and element = "nametheprice" and folder = "vmcustom"');
$db->query();
return True;
......
<?xml version="1.0" encoding="UTF-8" ?>
<install version="1.5" type="plugin" group="vmcustom" method="upgrade">
<name>VMCUSTOM_DONATION</name>
<extension version="2.5" type="plugin" group="vmcustom" method="upgrade">
<name>VMCUSTOM_NAMETHEPRICE</name>
<creationDate>2013-03-02</creationDate>
<author>Reinhold Kainhofer</author>
<authorUrl>http://www.open-tools.net/</authorUrl>
<copyright>Copyright (C) 2013 Reinhold Kainhofer. All rights reserved.</copyright>
<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.1.0</version>
<description>VMCUSTOM_DONATION_DESC</description>
<version>1.2</version>
<description>VMCUSTOM_NAMETHEPRICE_DESC</description>
<files>
<filename plugin="donation">donation.php</filename>
<filename>donation.script.php</filename>
<filename plugin="nametheprice">nametheprice.php</filename>
<filename>nametheprice.script.php</filename>
<folder>language</folder>
<folder>donation</folder>
<folder>nametheprice</folder>
<filename>index.html</filename>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_donation.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_donation.sys.ini</language>
<language tag="de-DE">de-DE/de-DE.plg_vmcustom_donation.ini</language>
<language tag="de-DE">de-DE/de-DE.plg_vmcustom_donation.sys.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_nametheprice.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_nametheprice.sys.ini</language>
<language tag="de-DE">de-DE/de-DE.plg_vmcustom_nametheprice.ini</language>
<language tag="de-DE">de-DE/de-DE.plg_vmcustom_nametheprice.sys.ini</language>
</languages>
<scriptfile>donation.script.php</scriptfile>
<scriptfile>nametheprice.script.php</scriptfile>
<vmconfig>
</vmconfig>
<params addpath="/administrator/components/com_virtuemart/elements">
<param type="vmjpluginwarning" />
</params>
</install>
</extension>
<?php
/*------------------------------------------------------------------------
# default.php - template for the donation input box
# default.php - template for the name the price (previously donation) input box
# ------------------------------------------------------------------------
# author Reinhold Kainhofer, The Open Tools Association
# copyright Copyright (C) 2013 open-tools.net. All Rights Reserved.
......@@ -11,25 +11,35 @@
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$class='vmcustom-settext'; ?>
$class='vmcustom-nametheprice';
$field = $viewData[0];
if (!defined('VM_VERSION') or VM_VERSION < 3) { // VM2:
$name = 'customPlugin['.$field->virtuemart_customfield_id.']['.$field->custom_element.'][customprice]';
} else {
$name = 'customProductData['.$field->virtuemart_product_id.']['.$field->virtuemart_custom_id.']['.$field->virtuemart_customfield_id .'][customprice]';
}
?>
<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 />
<input class="<?php echo $class ?>" type="text" value="" size="6" name="<?php echo $name?>"><?php echo CurrencyDisplay::getInstance ()->getSymbol(); ?><br />
<?php
// preventing 2 x load javascript
static $textinputjs;
if ($textinputjs) return true;
$textinputjs = true ;
static $namethepricejs;
if ($namethepricejs) return true;
$namethepricejs = true ;
//javascript to update price
$document = JFactory::getDocument();
$document->addScriptDeclaration('
$script = '
/* <![CDATA[ */
jQuery(document).ready( function($) {
jQuery(".vmcustom-textinput").keyup(function() {
var namethepricefunc = 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);
});
});
};
jQuery("body").on("updateVirtueMartProductDetail", namethepricefunc);
jQuery(document).ready(namethepricefunc);
/* ]]> */
');
\ No newline at end of file
';
$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