Does anyone have an idea how to add a symbol (like €) after a custom field ?
Thanks !
by css?
.xxxx::after {
content: '&euro';
}
I've didn't found a way to add a css class to a specific custom field,
do you know how to do ?
Also tried displaying custom field description on customfield.php sublayout, works but does'nt display in cart custom field list (see images above) ...
(http://www.webcomtoyou.com/01.JPG)
(http://www.webcomtoyou.com/02.JPG)
http://forum.virtuemart.net/index.php?topic=104795.0
http://forum.virtuemart.net/index.php?topic=79799.0
Oups, yes, sorry
VirtueMart 3.0.17.4
Joomla! 3.6.2
:-\
Custom fields are now templated .. u could over ride
com_virtuemart.3.0.16\components\com_virtuemart\sublayouts\customfield.php to add the label
but by css .. without a live url can't help..
Many thank's trying to help me ..
Here is the live url :
http://demo.magarantie.com/notre-offre/formule-solo/lavage
you'll see i've used custom-desc to display the € symbol but when adding to cart no symbol..
And i'm affraid it will be te same problem whith invoices ...
so u want € stored in the DB?
use jquery to add € to the field value
otherwise it is just a display thing at the cart end..
Ok, but, so sorry, can you tell me how to do this or is there any link where i cand find solution ?
Ok, so, after searching how to do, i've found this jquery code, works ! :
(function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}(jQuery));
$("input[name$='customProductData[1][25][31][comment]']").keyup(function(){
if ($(this).val().split('').pop() !== '€') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
But as you can see, it's depend on fiel name (here :"customProductData[1][25][31][comment]")
Is there a way to assign a jquery to one field or to one product detail page depending to product ID or Item page ?
Thank's again for your help
this is why the custom fields displays were made templatable....
add a unique id to the field
e.g. something like over ride components\com_virtuemart\sublayouts\customfields.php
if (!empty($field->display)){
?><div class="product-field-display" id="mycustomid_<?php echo $field->virtuemart_customfield_id; ?>"><?php echo $field->display ?></div><?php
}
then you can target in jquery #mycustomid_31
not tested
Thanks for the trick, so i've modified my code with :
(function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}(jQuery));
$("#mycustomid_31 input").keyup(function(){
if ($(this).val().split('').pop() !== '€') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
My question was how to implement it on product detail page, where to put it whith the right syntax .. ?
and, after that :
Is there a way to assign a jquery to one field or to one product detail page depending to product ID or Item page ?
That's not the most important question because i just have 7 products with this custom field but may be interresting for others VM users ..
I've made a js file calling euro.js
with this code in my default.php product detail page
<?php
JHtml::script(JUri::base() . 'templates/mytemplate/js/euro.js', true);
?>
Loading but not working ..
:(
http://docs.virtuemart.net/tutorials/development/196-the-vm-javascript-handler.html
e.g.
from std details
$j = "jQuery(document).ready(function($) {
Virtuemart.stopVmLoading();
var msg = '';
jQuery('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);
jQuery('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);
});";
vmJsApi::addJScript('vmPreloader',$j);
I've made a little working test file :
http://demo.magarantie.com/test.php
containing
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<script type="text/javascript" src="media/jui/js/jquery.min.js"></script>
<script type="text/javascript" src="templates/rt_acacia/js/euro.js"></script>
<title></title>
</head>
<body>
<div id="mycustomid_31">
<input></div>
</body></html>
The euro.js file :
$(window).load(function(){
(function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}(jQuery));
$("#mycustomid_31 input").keyup(function(){
if ($(this).val().split('').pop() !== '€') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
});//]]>
I'm loading the euro.js file on my product detail page:
http://demo.magarantie.com/notre-offre/formule-solo/lavage
having a custom field #mycustomid_31
Not working..
WTF ??
Quote from: GJC Web Design on September 12, 2016, 12:42:16 PM
http://docs.virtuemart.net/tutorials/development/196-the-vm-javascript-handler.html
e.g.
from std details
$j = "jQuery(document).ready(function($) {
Virtuemart.stopVmLoading();
var msg = '';
jQuery('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);
jQuery('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);
});";
vmJsApi::addJScript('vmPreloader',$j);
Sorry, i did'nt saw you reply ..but..hum...i don't understand what does it mean for me ..
What about my last post, should'nt this work anyway ?
Quote from: GJC Web Design on September 12, 2016, 12:42:16 PM
http://docs.virtuemart.net/tutorials/development/196-the-vm-javascript-handler.html
e.g.
from std details
$j = "jQuery(document).ready(function($) {
Virtuemart.stopVmLoading();
var msg = '';
jQuery('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);
jQuery('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);
});";
vmJsApi::addJScript('vmPreloader',$j);
Sorry, i did'nt saw your response ..
So for testing, i've putted in my template index file this script with id : euro :
<script id="euro" type="text/javascript">$(window).load(function(){
(function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}(jQuery));
$("#mycustomid_31 input").keyup(function(){
if ($(this).val().split('').pop() !== '€') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
});//]]>
</script>
I'm calling my script in product detail page like this :
...
<?php
vmJsApi::addJScript('euro');
?>
<div class="productdetails-view productdetails" >
...
Is this the right way ? doesn't work ..
Anyway, whithout putting the script in index header, just usin vmJsApi::addJScript('euro'); working, it call my euro.js script :
<script src="/demo/templates/rt_acacia/js/euro.js?vmver=9267" type="text/javascript" defer="defer"></script>
but still not working..
you write the script as rendered php in product detail page
then incl. it
$euro = '>$(window).load(function(){
(function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}(jQuery));
$("#mycustomid_31 input").keyup(function(){
if ($(this).val().split('').pop() !== '€') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
});';
vmJsApi::addJScript('euro',$euro);
check all your " & ' -- your mixing them
Many thank's for your precious help !
I've tried but asume that i'm a rookyie, here is my page code, whith blank result, you will find
// EURO function
and
// EURO calling script
<?php
/**
*
* Show the product details page
*
* @package VirtueMart
* @subpackage
* @author Max Milbers, Eugen Stranz, Max Galt
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2014 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 9185 2016-02-25 13:51:01Z Milbo $
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
/* Let's see if we found the product */
if (empty($this->product)) {
echo vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
echo '' . $this->continue_link_html;
return;
}
echo shopFunctionsF::renderVmSubLayout('askrecomjs',array('product'=>$this->product));
if(vRequest::getInt('print',false)){ ?>
<body onload="javascript:print();">
<?php } ?>
<div class="productdetails-view productdetails" >
<?php
// EURO function
$euro = '>$(window).load(function(){
(function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}(jQuery));
$("#mycustomid_31 input").keyup(function(){
if ($(this).val().split('').pop() !== '€') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
});';
// EURO END
?>
<?php
// Product Navigation
if (VmConfig::get('product_navigation', 1)) {
?>
<div class="product-neighbours">
<?php
if (!empty($this->product->neighbours ['previous'][0])) {
$prev_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['previous'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE);
echo JHtml::_('link', $prev_link, $this->product->neighbours ['previous'][0]
['product_name'], array('rel'=>'prev', 'class' => 'previous-page','data-dynamic-update' => '1'));
}
if (!empty($this->product->neighbours ['next'][0])) {
$next_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['next'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE);
echo JHtml::_('link', $next_link, $this->product->neighbours ['next'][0] ['product_name'], array('rel'=>'next','class' => 'next-page','data-dynamic-update' => '1'));
}
?>
<div class="clear"></div>
</div>
<?php } // Product Navigation END
?>
<?php // Product Title ?>
<div class="cat-<?php echo $this->category->virtuemart_category_id; ?> fond-image-produit">
<h2 class="produit-categorie"><?php echo $this->category->category_name; ?></h2>
<h1 itemprop="name" class="titre-produit"><?php echo $this->product->product_name ?></h1>
<div class="image-produit-detail"><?php
echo $this->loadTemplate('images');
?></div>
<div class="prix-produit"><div class="fleche-produit"> </div>
<?php
echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$this->product,'currency'=>$this->currency));
?> <div style="float: left;margin-left: 9px;" class="par-an">/an</div>
</div>
<div><img src="images/personnages/perso-30.png" alt="perso 30" style="margin-right: -5px; float: right;margin-top:-137px" /></div>
<?php // Product Title END ?>
</div>
<?php // afterDisplayTitle Event
echo $this->product->event->afterDisplayTitle ?>
<?php
// Product Edit Link
echo $this->edit_link;
// Product Edit Link END
?>
<?php
// PDF - Print - Email Icon
if (VmConfig::get('show_emailfriend') || VmConfig::get('show_printicon') || VmConfig::get('pdf_icon')) {
?>
<div class="icons">
<?php
$link = 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->virtuemart_product_id;
echo $this->linkIcon($link . '&format=pdf', 'COM_VIRTUEMART_PDF', 'pdf_button', 'pdf_icon', false);
//echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon');
echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon',false,true,false,'class="printModal"');
$MailLink = 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component';
echo $this->linkIcon($MailLink, 'COM_VIRTUEMART_EMAIL', 'emailButton', 'show_emailfriend', false,true,false,'class="recommened-to-friend"');
?>
<div class="clear"></div>
</div>
<?php } // PDF - Print - Email Icon END
?>
<?php
// Product Short Description
if (!empty($this->product->product_s_desc)) {
?>
<div class="product-short-description">
<?php
/** @todo Test if content plugins modify the product description */
echo nl2br($this->product->product_s_desc);
?>
</div>
<?php
} // Product Short Description END
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'ontop'));
?>
<div class="vm-product-container">
<div class="vm-product-media-container">
</div>
<div class="vm-product-details-container">
</div>
<div class="clear"></div>
</div>
<?php
$count_images = count ($this->product->images);
if ($count_images > 1) {
echo $this->loadTemplate('images_additional');
}
// event onContentBeforeDisplay
echo $this->product->event->beforeDisplayContent; ?>
<?php
//echo ($this->product->product_in_stock - $this->product->product_ordered);
// Product Description
if (!empty($this->product->product_desc)) {
?>
<div class="product-description" >
<div class="spacer-buy-area">
<?php
// TODO in Multi-Vendor not needed at the moment and just would lead to confusion
/* $link = JRoute::_('index2.php?option=com_virtuemart&view=virtuemart&task=vendorinfo&virtuemart_vendor_id='.$this->product->virtuemart_vendor_id);
$text = vmText::_('COM_VIRTUEMART_VENDOR_FORM_INFO_LBL');
echo '<span class="bold">'. vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS_VENDOR_LBL'). '</span>'; ?><a class="modal" href="<?php echo $link ?>"><?php echo $text ?></a><br />
*/
?>
<?php
echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>$this->showRating,'product'=>$this->product));
if (is_array($this->productDisplayShipments)) {
foreach ($this->productDisplayShipments as $productDisplayShipment) {
echo $productDisplayShipment . '<br />';
}
}
if (is_array($this->productDisplayPayments)) {
foreach ($this->productDisplayPayments as $productDisplayPayment) {
echo $productDisplayPayment . '<br />';
}
}
//In case you are not happy using everywhere the same price display fromat, just create your own layout
//in override /html/fields and use as first parameter the name of your file
?> <div class="clear"></div><?php
echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product));
echo shopFunctionsF::renderVmSubLayout('stockhandle',array('product'=>$this->product));
// Ask a question about this product
if (VmConfig::get('ask_question', 0) == 1) {
$askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE);
?>
<?php
}
?>
<?php
// Manufacturer of the Product
if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
echo $this->loadTemplate('manufacturer');
}
?>
</div>
<?php /** @todo Test if content plugins modify the product description */ ?>
<div class="description-categorie"><?php echo $this->category->category_description; ?></div>
<?php echo $this->product->product_desc; ?>
</div>
<div style="font-size: 13px;">
<strong>Un doute sur la possibilité de garantir votre appareil ?</strong>
</div>
<?php
// Ask a question about this product
if (VmConfig::get('ask_question', 0) == 1) {
$askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE);
}
?>
<div class="ask-a-question">
<a class="ask-a-question" href="<?php echo $askquestion_url ?>" rel="nofollow" ><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a>
</div>
<?php if ($this->category->virtuemart_category_id == 2) { ?>
<div class="idee-solo">
<p class="success" style="text-align: justify;"><img src="images/bulb_PNG1250.png" alt="bulb PNG1250" width="39" height="39" style="vertical-align: middle; float: left;" />Pour un choix Malin, <strong>Magarantie.com</strong> vous propose pour quelques euros de plus seulement de garantir l'ensemble des appareils de la même catégorie en optant pour la <a class="idee" href="index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=6&Itemid=380">formule Pack Ménager</a> !</p>
</div>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-solo.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php if ($this->category->virtuemart_category_id == 3) { ?>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-pack.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php if ($this->category->virtuemart_category_id == 4) { ?>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-pack.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php if ($this->category->virtuemart_category_id == 5) { ?>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-axa.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php
} // Product Description END
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'normal'));
// Product Packaging
$product_packaging = '';
if ($this->product->product_box) {
?>
<div class="product-box">
<?php
echo vmText::_('COM_VIRTUEMART_PRODUCT_UNITS_IN_BOX') .$this->product->product_box;
?>
</div>
<?php } // Product Packaging END ?>
<?php
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'onbot'));
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products','customTitle' => true ));
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_categories','class'=> 'product-related-categories'));
?>
<?php // onContentAfterDisplay event
echo $this->product->event->afterDisplayContent;
echo $this->loadTemplate('reviews');
// Show child categories
if (VmConfig::get('showCategory', 1)) {
echo $this->loadTemplate('showcategory');
}
$j = 'jQuery(document).ready(function($) {
Virtuemart.product(jQuery("form.product"));
$("form.js-recalculate").each(function(){
if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) {
var id= $(this).find(\'input[name="virtuemart_product_id[]"]\').val();
Virtuemart.setproducttype($(this),id);
}
});
});';
//vmJsApi::addJScript('recalcReady',$j);
/** GALT
* Notice for Template Developers!
* Templates must set a Virtuemart.container variable as it takes part in
* dynamic content update.
* This variable points to a topmost element that holds other content.
*/
$j = "Virtuemart.container = jQuery('.productdetails-view');
Virtuemart.containerSelector = '.productdetails-view';";
vmJsApi::addJScript('ajaxContent',$j);
// EURO calling script
vmJsApi::addJScript('euro',$euro);
if(VmConfig::get ('jdynupdate', TRUE)){
$j = "jQuery(document).ready(function($) {
Virtuemart.stopVmLoading();
var msg = '';
jQuery('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);
jQuery('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);
});";
vmJsApi::addJScript('vmPreloader',$j);
}
echo vmJsApi::writeJS();
if ($this->product->prices['salesPrice'] > 0) {
echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product, 'currency'=>$this->currency, 'showRating'=>$this->showRating));
}
?>
</div>
:-\
I made a huge mistake, sorry, so tirred
That's what i think i have to do, but still not working :
<div class="productdetails-view productdetails" >
<script type="text/javascript">
// EURO function
$euro = '$(window).load(function(){
(function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}(jQuery));
$("#mycustomid_31 input").keyup(function(){
if ($(this).val().split('').pop() !== '€') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
});';
// EURO END
</script>
<?php
vmJsApi::addJScript('euro',$euro);
?>
<?php
// Product Navigation
if (VmConfig::get('product_navigation', 1)) {
?>
"Notice: Undefined variable: euro"
your writing php .. u don't need stuff like <script type="text/javascript">
Ok, so that what i've done here :
<?php
/**
*
* Show the product details page
*
* @package VirtueMart
* @subpackage
* @author Max Milbers, Eugen Stranz, Max Galt
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2014 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 9185 2016-02-25 13:51:01Z Milbo $
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
/* Let's see if we found the product */
if (empty($this->product)) {
echo vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
echo '' . $this->continue_link_html;
return;
}
echo shopFunctionsF::renderVmSubLayout('askrecomjs',array('product'=>$this->product));
if(vRequest::getInt('print',false)){ ?>
<body onload="javascript:print();">
<?php } ?>
<div class="productdetails-view productdetails" >
<?php
// EURO function
$euro = '>$(window).load(function(){
(function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}(jQuery));
$("#mycustomid_31 input").keyup(function(){
if ($(this).val().split('').pop() !== '€') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
});';
// EURO END
?>
<?php
// Product Navigation
if (VmConfig::get('product_navigation', 1)) {
?>
<div class="product-neighbours">
<?php
if (!empty($this->product->neighbours ['previous'][0])) {
$prev_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['previous'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE);
echo JHtml::_('link', $prev_link, $this->product->neighbours ['previous'][0]
['product_name'], array('rel'=>'prev', 'class' => 'previous-page','data-dynamic-update' => '1'));
}
if (!empty($this->product->neighbours ['next'][0])) {
$next_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['next'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE);
echo JHtml::_('link', $next_link, $this->product->neighbours ['next'][0] ['product_name'], array('rel'=>'next','class' => 'next-page','data-dynamic-update' => '1'));
}
?>
<div class="clear"></div>
</div>
<?php } // Product Navigation END
?>
<?php // Product Title ?>
<div class="cat-<?php echo $this->category->virtuemart_category_id; ?> fond-image-produit">
<h2 class="produit-categorie"><?php echo $this->category->category_name; ?></h2>
<h1 itemprop="name" class="titre-produit"><?php echo $this->product->product_name ?></h1>
<div class="image-produit-detail"><?php
echo $this->loadTemplate('images');
?></div>
<div class="prix-produit"><div class="fleche-produit"> </div>
<?php
echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$this->product,'currency'=>$this->currency));
?> <div style="float: left;margin-left: 9px;" class="par-an">/an</div>
</div>
<div><img src="images/personnages/perso-30.png" alt="perso 30" style="margin-right: -5px; float: right;margin-top:-137px" /></div>
<?php // Product Title END ?>
</div>
<?php // afterDisplayTitle Event
echo $this->product->event->afterDisplayTitle ?>
<?php
// Product Edit Link
echo $this->edit_link;
// Product Edit Link END
?>
<?php
// PDF - Print - Email Icon
if (VmConfig::get('show_emailfriend') || VmConfig::get('show_printicon') || VmConfig::get('pdf_icon')) {
?>
<div class="icons">
<?php
$link = 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->virtuemart_product_id;
echo $this->linkIcon($link . '&format=pdf', 'COM_VIRTUEMART_PDF', 'pdf_button', 'pdf_icon', false);
//echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon');
echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon',false,true,false,'class="printModal"');
$MailLink = 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component';
echo $this->linkIcon($MailLink, 'COM_VIRTUEMART_EMAIL', 'emailButton', 'show_emailfriend', false,true,false,'class="recommened-to-friend"');
?>
<div class="clear"></div>
</div>
<?php } // PDF - Print - Email Icon END
?>
<?php
// Product Short Description
if (!empty($this->product->product_s_desc)) {
?>
<div class="product-short-description">
<?php
/** @todo Test if content plugins modify the product description */
echo nl2br($this->product->product_s_desc);
?>
</div>
<?php
} // Product Short Description END
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'ontop'));
?>
<div class="vm-product-container">
<div class="vm-product-media-container">
</div>
<div class="vm-product-details-container">
</div>
<div class="clear"></div>
</div>
<?php
$count_images = count ($this->product->images);
if ($count_images > 1) {
echo $this->loadTemplate('images_additional');
}
// event onContentBeforeDisplay
echo $this->product->event->beforeDisplayContent; ?>
<?php
//echo ($this->product->product_in_stock - $this->product->product_ordered);
// Product Description
if (!empty($this->product->product_desc)) {
?>
<div class="product-description" >
<div class="spacer-buy-area">
<?php
// TODO in Multi-Vendor not needed at the moment and just would lead to confusion
/* $link = JRoute::_('index2.php?option=com_virtuemart&view=virtuemart&task=vendorinfo&virtuemart_vendor_id='.$this->product->virtuemart_vendor_id);
$text = vmText::_('COM_VIRTUEMART_VENDOR_FORM_INFO_LBL');
echo '<span class="bold">'. vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS_VENDOR_LBL'). '</span>'; ?><a class="modal" href="<?php echo $link ?>"><?php echo $text ?></a><br />
*/
?>
<?php
echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>$this->showRating,'product'=>$this->product));
if (is_array($this->productDisplayShipments)) {
foreach ($this->productDisplayShipments as $productDisplayShipment) {
echo $productDisplayShipment . '<br />';
}
}
if (is_array($this->productDisplayPayments)) {
foreach ($this->productDisplayPayments as $productDisplayPayment) {
echo $productDisplayPayment . '<br />';
}
}
//In case you are not happy using everywhere the same price display fromat, just create your own layout
//in override /html/fields and use as first parameter the name of your file
?> <div class="clear"></div><?php
echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product));
echo shopFunctionsF::renderVmSubLayout('stockhandle',array('product'=>$this->product));
// Ask a question about this product
if (VmConfig::get('ask_question', 0) == 1) {
$askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE);
?>
<?php
}
?>
<?php
// Manufacturer of the Product
if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
echo $this->loadTemplate('manufacturer');
}
?>
</div>
<?php /** @todo Test if content plugins modify the product description */ ?>
<div class="description-categorie"><?php echo $this->category->category_description; ?></div>
<?php echo $this->product->product_desc; ?>
</div>
<div style="font-size: 13px;">
<strong>Un doute sur la possibilité de garantir votre appareil ?</strong>
</div>
<?php
// Ask a question about this product
if (VmConfig::get('ask_question', 0) == 1) {
$askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE);
}
?>
<div class="ask-a-question">
<a class="ask-a-question" href="<?php echo $askquestion_url ?>" rel="nofollow" ><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a>
</div>
<?php if ($this->category->virtuemart_category_id == 2) { ?>
<div class="idee-solo">
<p class="success" style="text-align: justify;"><img src="images/bulb_PNG1250.png" alt="bulb PNG1250" width="39" height="39" style="vertical-align: middle; float: left;" />Pour un choix Malin, <strong>Magarantie.com</strong> vous propose pour quelques euros de plus seulement de garantir l'ensemble des appareils de la même catégorie en optant pour la <a class="idee" href="index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=6&Itemid=380">formule Pack Ménager</a> !</p>
</div>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-solo.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php if ($this->category->virtuemart_category_id == 3) { ?>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-pack.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php if ($this->category->virtuemart_category_id == 4) { ?>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-pack.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php if ($this->category->virtuemart_category_id == 5) { ?>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-axa.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php
} // Product Description END
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'normal'));
// Product Packaging
$product_packaging = '';
if ($this->product->product_box) {
?>
<div class="product-box">
<?php
echo vmText::_('COM_VIRTUEMART_PRODUCT_UNITS_IN_BOX') .$this->product->product_box;
?>
</div>
<?php } // Product Packaging END ?>
<?php
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'onbot'));
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products','customTitle' => true ));
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_categories','class'=> 'product-related-categories'));
?>
<?php // onContentAfterDisplay event
echo $this->product->event->afterDisplayContent;
echo $this->loadTemplate('reviews');
// Show child categories
if (VmConfig::get('showCategory', 1)) {
echo $this->loadTemplate('showcategory');
}
$j = 'jQuery(document).ready(function($) {
Virtuemart.product(jQuery("form.product"));
$("form.js-recalculate").each(function(){
if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) {
var id= $(this).find(\'input[name="virtuemart_product_id[]"]\').val();
Virtuemart.setproducttype($(this),id);
}
});
});';
//vmJsApi::addJScript('recalcReady',$j);
/** GALT
* Notice for Template Developers!
* Templates must set a Virtuemart.container variable as it takes part in
* dynamic content update.
* This variable points to a topmost element that holds other content.
*/
$j = "Virtuemart.container = jQuery('.productdetails-view');
Virtuemart.containerSelector = '.productdetails-view';";
vmJsApi::addJScript('ajaxContent',$j);
// EURO calling script
vmJsApi::addJScript('euro',$euro);
if(VmConfig::get ('jdynupdate', TRUE)){
$j = "jQuery(document).ready(function($) {
Virtuemart.stopVmLoading();
var msg = '';
jQuery('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);
jQuery('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);
});";
vmJsApi::addJScript('vmPreloader',$j);
}
echo vmJsApi::writeJS();
if ($this->product->prices['salesPrice'] > 0) {
echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product, 'currency'=>$this->currency, 'showRating'=>$this->showRating));
}
?>
</div>
But result is a blank page ..
the syntax highlighting shows u it couldn't possibly work!
Quotecheck all your " & ' -- your mixing them
be consistent -- turn on error reporting etc etc
...I'm little bit lost, now ...what i'm suppose to do ?
replace ' by " ?
I've just copied the code you sent in reply 16:10:06
and pasted it, anyway that is the code working in my test page so, yes, i'm lost ...
:-\
So sorry to waste your time
hmmm .. this is basic syntax...
within the opening and closing php ' you obviously can't have any other ' unless you escape them -> \'
or better use "
you need to check your code for consistency..
So, spent lot of time trying many things, here is my last attempt, a parse error on last line but really unable to understand..
and the script tested on
http://phptester.net/
reveal FATAL ERROR syntax error, unexpected '').pop() !== '' (T_CONSTANT_ENCAPSED_STRING) on line
if ($(this).val().split('').pop() !== \'€\') {
Anyway, i really don't understand why it isn't possible to run this script that working outside of VM :o
<?php
// EURO function
$euro = '$(window).load(function()
{
(function($)
{
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd("character", pos);
range.moveStart("character", pos);
range.select();
}
}
}
(jQuery));
$("#mycustomid_31 input").keyup(function()
{
if ($(this).val().split('').pop() !== \'€\') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
});';
?>
QuoteAnyway, i really don't understand why it isn't possible to run this script that working outside of VM :o
as explained in the vmjsapi instructions how can u load a js from the head if your refreshing the page content by ajax?
use "" !!!
the error explains it exactly
many thanks again for your patience and kindness, finally no more errors but not working ...
I tried to put it in different places, differents files, customfields.php, custom field.php ...
here is my final defaut.php productdetails page :
<?php
/**
*
* Show the product details page
*
* @package VirtueMart
* @subpackage
* @author Max Milbers, Eugen Stranz, Max Galt
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2014 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 9185 2016-02-25 13:51:01Z Milbo $
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
/* Let's see if we found the product */
if (empty($this->product)) {
echo vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
echo '' . $this->continue_link_html;
return;
}
echo shopFunctionsF::renderVmSubLayout('askrecomjs',array('product'=>$this->product));
if(vRequest::getInt('print',false)){ ?>
<body onload="javascript:print();">
<?php } ?>
<div class="productdetails-view productdetails" >
<?php
// EURO function
$euro = '$(window).load(function(){
{
(function($)
{
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd("character", pos);
range.moveStart("character", pos);
range.select();
}
}
}
(jQuery));
$("#mycustomid_31 input").keyup(function()
{
if ($(this).val().split("").pop() !== \'€\') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
});';
?>
<?php
vmJsApi::addJScript('euro',$euro);
?>
<?php
// Product Navigation
if (VmConfig::get('product_navigation', 1)) {
?>
<div class="product-neighbours">
<?php
if (!empty($this->product->neighbours ['previous'][0])) {
$prev_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['previous'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE);
echo JHtml::_('link', $prev_link, $this->product->neighbours ['previous'][0]
['product_name'], array('rel'=>'prev', 'class' => 'previous-page','data-dynamic-update' => '1'));
}
if (!empty($this->product->neighbours ['next'][0])) {
$next_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['next'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE);
echo JHtml::_('link', $next_link, $this->product->neighbours ['next'][0] ['product_name'], array('rel'=>'next','class' => 'next-page','data-dynamic-update' => '1'));
}
?>
<div class="clear"></div>
</div>
<?php } // Product Navigation END
?>
<?php // Product Title ?>
<div class="cat-<?php echo $this->category->virtuemart_category_id; ?> fond-image-produit">
<h2 class="produit-categorie"><?php echo $this->category->category_name; ?></h2>
<h1 itemprop="name" class="titre-produit"><?php echo $this->product->product_name ?></h1>
<div class="image-produit-detail"><?php
echo $this->loadTemplate('images');
?></div>
<div class="prix-produit"><div class="fleche-produit"> </div>
<?php
echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$this->product,'currency'=>$this->currency));
?> <div style="float: left;margin-left: 9px;" class="par-an">/an</div>
</div>
<div><img src="images/personnages/perso-30.png" alt="perso 30" style="margin-right: -5px; float: right;margin-top:-137px" /></div>
<?php // Product Title END ?>
</div>
<?php // afterDisplayTitle Event
echo $this->product->event->afterDisplayTitle ?>
<?php
// Product Edit Link
echo $this->edit_link;
// Product Edit Link END
?>
<?php
// PDF - Print - Email Icon
if (VmConfig::get('show_emailfriend') || VmConfig::get('show_printicon') || VmConfig::get('pdf_icon')) {
?>
<div class="icons">
<?php
$link = 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->virtuemart_product_id;
echo $this->linkIcon($link . '&format=pdf', 'COM_VIRTUEMART_PDF', 'pdf_button', 'pdf_icon', false);
//echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon');
echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon',false,true,false,'class="printModal"');
$MailLink = 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component';
echo $this->linkIcon($MailLink, 'COM_VIRTUEMART_EMAIL', 'emailButton', 'show_emailfriend', false,true,false,'class="recommened-to-friend"');
?>
<div class="clear"></div>
</div>
<?php } // PDF - Print - Email Icon END
?>
<?php
// Product Short Description
if (!empty($this->product->product_s_desc)) {
?>
<div class="product-short-description">
<?php
/** @todo Test if content plugins modify the product description */
echo nl2br($this->product->product_s_desc);
?>
</div>
<?php
} // Product Short Description END
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'ontop'));
?>
<div class="vm-product-container">
<div class="vm-product-media-container">
</div>
<div class="vm-product-details-container">
</div>
<div class="clear"></div>
</div>
<?php
$count_images = count ($this->product->images);
if ($count_images > 1) {
echo $this->loadTemplate('images_additional');
}
// event onContentBeforeDisplay
echo $this->product->event->beforeDisplayContent; ?>
<?php
//echo ($this->product->product_in_stock - $this->product->product_ordered);
// Product Description
if (!empty($this->product->product_desc)) {
?>
<div class="product-description" >
<div class="spacer-buy-area">
<?php
// TODO in Multi-Vendor not needed at the moment and just would lead to confusion
/* $link = JRoute::_('index2.php?option=com_virtuemart&view=virtuemart&task=vendorinfo&virtuemart_vendor_id='.$this->product->virtuemart_vendor_id);
$text = vmText::_('COM_VIRTUEMART_VENDOR_FORM_INFO_LBL');
echo '<span class="bold">'. vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS_VENDOR_LBL'). '</span>'; ?><a class="modal" href="<?php echo $link ?>"><?php echo $text ?></a><br />
*/
?>
<?php
echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>$this->showRating,'product'=>$this->product));
if (is_array($this->productDisplayShipments)) {
foreach ($this->productDisplayShipments as $productDisplayShipment) {
echo $productDisplayShipment . '<br />';
}
}
if (is_array($this->productDisplayPayments)) {
foreach ($this->productDisplayPayments as $productDisplayPayment) {
echo $productDisplayPayment . '<br />';
}
}
//In case you are not happy using everywhere the same price display fromat, just create your own layout
//in override /html/fields and use as first parameter the name of your file
?> <div class="clear"></div><?php
echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product));
echo shopFunctionsF::renderVmSubLayout('stockhandle',array('product'=>$this->product));
// Ask a question about this product
if (VmConfig::get('ask_question', 0) == 1) {
$askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE);
?>
<?php
}
?>
<?php
// Manufacturer of the Product
if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
echo $this->loadTemplate('manufacturer');
}
?>
</div>
<?php /** @todo Test if content plugins modify the product description */ ?>
<div class="description-categorie"><?php echo $this->category->category_description; ?></div>
<?php echo $this->product->product_desc; ?>
</div>
<div style="font-size: 13px;">
<strong>Un doute sur la possibilité de garantir votre appareil ?</strong>
</div>
<?php
// Ask a question about this product
if (VmConfig::get('ask_question', 0) == 1) {
$askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE);
}
?>
<div class="ask-a-question">
<a class="ask-a-question" href="<?php echo $askquestion_url ?>" rel="nofollow" ><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a>
</div>
<?php if ($this->category->virtuemart_category_id == 2) { ?>
<div class="idee-solo">
<p class="success" style="text-align: justify;"><img src="images/bulb_PNG1250.png" alt="bulb PNG1250" width="39" height="39" style="vertical-align: middle; float: left;" />Pour un choix Malin, <strong>Magarantie.com</strong> vous propose pour quelques euros de plus seulement de garantir l'ensemble des appareils de la même catégorie en optant pour la <a class="idee" href="index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=6&Itemid=380">formule Pack Ménager</a> !</p>
</div>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-solo.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php if ($this->category->virtuemart_category_id == 3) { ?>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-pack.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php if ($this->category->virtuemart_category_id == 4) { ?>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-pack.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php if ($this->category->virtuemart_category_id == 5) { ?>
<div class="lien-pdf">
<p style="margin-left: 14px;"><a class="pdf" href="notice-information-axa.pdf" target="_blank">Consultez la notice d'information</a></p>
</div>
<?php }?>
<?php
} // Product Description END
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'normal'));
// Product Packaging
$product_packaging = '';
if ($this->product->product_box) {
?>
<div class="product-box">
<?php
echo vmText::_('COM_VIRTUEMART_PRODUCT_UNITS_IN_BOX') .$this->product->product_box;
?>
</div>
<?php } // Product Packaging END ?>
<?php
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'onbot'));
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products','customTitle' => true ));
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_categories','class'=> 'product-related-categories'));
?>
<?php // onContentAfterDisplay event
echo $this->product->event->afterDisplayContent;
echo $this->loadTemplate('reviews');
// Show child categories
if (VmConfig::get('showCategory', 1)) {
echo $this->loadTemplate('showcategory');
}
$j = 'jQuery(document).ready(function($) {
Virtuemart.product(jQuery("form.product"));
$("form.js-recalculate").each(function(){
if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) {
var id= $(this).find(\'input[name="virtuemart_product_id[]"]\').val();
Virtuemart.setproducttype($(this),id);
}
});
});';
//vmJsApi::addJScript('recalcReady',$j);
/** GALT
* Notice for Template Developers!
* Templates must set a Virtuemart.container variable as it takes part in
* dynamic content update.
* This variable points to a topmost element that holds other content.
*/
$j = "Virtuemart.container = jQuery('.productdetails-view');
Virtuemart.containerSelector = '.productdetails-view';";
vmJsApi::addJScript('ajaxContent',$j);
if(VmConfig::get ('jdynupdate', TRUE)){
$j = "jQuery(document).ready(function($) {
Virtuemart.stopVmLoading();
var msg = '';
jQuery('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);
jQuery('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);
});";
vmJsApi::addJScript('vmPreloader',$j);
}
echo vmJsApi::writeJS();
if ($this->product->prices['salesPrice'] > 0) {
echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product, 'currency'=>$this->currency, 'showRating'=>$this->showRating));
}
?>
</div>
should be at the bottom with the rest of the js
does it load?
can u see it?
is there console errors?
I can see it, no error
I tried :
- At the very end of productdetail, before last </div>
Not loaded
- before or after
$j = "Virtuemart.container = jQuery('.productdetails-view');
Virtuemart.containerSelector = '.productdetails-view';";
vmJsApi::addJScript('ajaxContent',$j);
Loaded, not working
- in cutomfield.php after
if ($productCustom->field_type == "E") {
not loaded
- at the end of cutomfield.php
Loaded, not working
Is there a possibility that
$(window).load(function()
{
(function($)
{
is a wrong syntax for VM ?
Here is the last actual code i'm using in productdetail :
http://demo.magarantie.com/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=1&Itemid=357
$euro = '$(window).load(function()
{
(function($)
{
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd("character", pos);
range.moveStart("character", pos);
range.select();
}
}
}
(jQuery));
$("#mycustomid_31 input").keyup(function()
{
if ($(this).val().split("").pop() !== \'€\') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
});';
vmJsApi::addJScript('euro',$euro);
:-[
So sorry, finally i've found an error
Uncaught TypeError: $(...).load is not a function
But this function works in original code ..
:o
(http://www.webcomtoyou.com/04.JPG)
YESSSSSSSSSS !!!
By the end, i found :
Just had to replace
euro = '$(window).load(function()
by
$euro = 'jQuery(document).ready(function($)
Many, many thanks again for you patience !!!!!!!!
Quote from: GJC Web Design on September 13, 2016, 12:36:21 PM
as explained in the vmjsapi instructions how can u load a js from the head if your refreshing the page content by ajax?
Finally, it's possible to load js from the head ...regardless your refreshing the page content by ajax;
No need to use php code, i think it could be useful with lot of product to modify the
" $("#mycustomid_X input").keyup(function(){" line but, in my case, here is the solution :
because i have only 7 products whith this needed field,
in defaut.php productdetail page, after
$j = "Virtuemart.container = jQuery('.productdetails-view');
Virtuemart.containerSelector = '.productdetails-view';";
vmJsApi::addJScript('ajaxContent',$j);
I putted :
if ($this->product->virtuemart_product_id == 1) {
vmJsApi::addJScript('euro1');
}
if ($this->product->virtuemart_product_id == 2) {
vmJsApi::addJScript('euro2');
}
if ($this->product->virtuemart_product_id == 3) {
vmJsApi::addJScript('euro3');
}
...
and here is the euro1.js file located in templates/mytemplate/js :
jQuery(document).ready(function($)
{
(function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}(jQuery));
$("#mycustomid_X input").keyup(function(){
if ($(this).val().split('').pop() !== '€') {
$(this).val($(this).val() + " €");
$(this).setCursorPosition( $(this).val().length - 2)
}
});
});
where #mycustomid_X is the ID obtained by modifing customfields.php
if (!empty($field->display)){
?><div class="product-field-display" id="mycustomid_<?php echo $field->virtuemart_customfield_id; ?>"><?php echo $field->display ?></div><?php
}
Again and again thank's a lot for your precious help !!!
Well done..
but your not in the above loading from the joomla system "in the head" (which is the problem with ajax)
your using the vmjsapi which as in the docs can load any resource within the page
It doesn't really matter where the resource is
Ok, understand, have a nice day !!
;)
Custom fields can be used to store additional contact information such as a subscriber's address, city, country, or phone number. They're also great for collecting unique information about subscribers to help you plan more relevant and personalized email content.