Plugin that make VM2 costum fiels required, not working well

Rate this topic: Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.1.00 out of 6 based on 1 vote(s)
GK User
Mon Jun 30, 2014 10:18 am
Reply with quote
Report this post
Hy there, i have a plugin, have installed in joomla, activated and make the option to be required on the costum fields place, by selecting yes to it...

But when i go to override the file omponents/com_virtuemart/views/productdetails/tmpl/default_addtocart.php, nothing happens, so i believe that the right file to add the code is in
public_html/templates/gk_storebox/html/com_virtuemart/productdetails/default.php, when adding the code, like the instructions, cant add right after Just below: echo JHTML::tooltip (vmText::_($field->custom_tip), vmText::_ ($field->custom_title), 'tooltip.png'); gives a blank page, and after the code: $custom_title = null ;
if(is_array($this->product->customfields) && count($this->product->customfields)) :
foreach ($this->product->customfields as $field) : ?>
<div class="product-field product-field-type-<?php echo $field->field_type ?>">
<?php if ($field->custom_title != $custom_title) : ?>
<span class="product-fields-title" ><?php echo JText::_($field->custom_title); ?></span>
<?php if ($field->custom_tip) :
echo JHTML::tooltip($field->custom_tip, JText::_($field->custom_title), 'tooltip.png');
endif;
endif; ?>

The page works, but the plugin dont block when adding the product to cart...


The Plugin seller instructions:

Edit the “default_addtocart.php” file in Virtuemart.
Please note: if you are using a custom Virtuemart theme you would need to edit the associated file for the custom theme.
We have included a few different version of Virtuemart’s default addtocart file. You can use this to simply override the existing file on your web server. We are not responsible for possible variations in coding between versions. To ‘play it safe’ open the file in a text editor such as Notepadd++ and add the code.

The path to the file: components/com_virtuemart/views/productdetails/tmpl/default_addtocart.php


Around line 20, just below “defined('_JEXEC') or die('Restricted access');”

Add this code block:
/* Required Custom Fields- Start */
JHtml::_('behavior.formvalidation');
$doc = JFactory::getDocument();
$doc->addScriptDeclaration('
jQuery(document).ready(function(){
form = jQuery("form.product")
if(form.attr("name") != "formvalidate"){
form.attr("name","formvalidate");
}
addcart = form.find("input.addtocart-button");
addcart.addClass("validate");
form.find(":input").each(function(){
if(jQuery(this).attr("required"))
jQuery(this).addClass("required");
});
addcart.unbind( "click" );
addcart.click(function(){
myform = document.formvalidate;
document.formvalidator=new JFormValidator;
if(document.formvalidator.isValid(myform)){
Virtuemart.sendtocart(jQuery(myform));
return false;
} else {return false;}
});
});
');
/* Required Custom Fields- End */



Around Line: 74.
Just below: echo JHTML::tooltip (vmText::_($field->custom_tip), vmText::_ ($field->custom_title), 'tooltip.png');

Add this code block. Including <?php and the closing ?>:
<?php
/* Required Custom Fields- Start */
JPluginHelper::importPlugin('system');
$dispatcher = JDispatcher::getInstance();
$results = $dispatcher->trigger( 'onDisplayCustomField', array(&$field) );
/* Required Custom Fields- End */
?>


Could anyone give me a help?

Thanks
User avatar
Fresh Boarder

teitbite
Tue Jul 01, 2014 7:57 am
Reply with quote
Report this post
Hi

I'm sorry, but this is a modyfication not a plugin, whis can be working separately. All I can assist is to remove our override and follow the developer instructions in VM default files.
User avatar
Moderator

GK User
Tue Jul 01, 2014 7:47 pm
Reply with quote
Report this post
So there is a override in this template that is blocking the plugin from working, right???
There ins't a way to add the code to work with the plugin that i have bought?

This is the full instructions that the seller give with the plugin...

Step 1:

Install the plugin through Joomla’s “Extension Manager”
Step 2:

Activate the plugin through Joomla’s “Plugin-In Manager”
Step 3:

Create or edit a custom field in Virtuemart.
Select “Yes” to the Required Field option if you want to prevent a buyer from adding an item to the shopping cart until information has been entered.

virtuemart custom field install
Step 4:

Edit the “default_addtocart.php” file in Virtuemart.
Please note: if you are using a custom Virtuemart theme you would need to edit the associated file for the custom theme.
We have included a few different version of Virtuemart’s default addtocart file. You can use this to simply override the existing file on your web server. We are not responsible for possible variations in coding between versions. To ‘play it safe’ open the file in a text editor such as Notepadd++ and add the code.
The path to the file: components/com_virtuemart/views/productdetails/tmpl/default_addtocart.php


Around line 20, just below “defined('_JEXEC') or die('Restricted access');”

Add this code block:
/* Required Custom Fields- Start */
JHtml::_('behavior.formvalidation');
$doc = JFactory::getDocument();
$doc->addScriptDeclaration('
jQuery(document).ready(function(){
form = jQuery("form.product")
if(form.attr("name") != "formvalidate"){
form.attr("name","formvalidate");
}
addcart = form.find("input.addtocart-button");
addcart.addClass("validate");
form.find(":input").each(function(){
if(jQuery(this).attr("required"))
jQuery(this).addClass("required");
});
addcart.unbind( "click" );
addcart.click(function(){
myform = document.formvalidate;
document.formvalidator=new JFormValidator;
if(document.formvalidator.isValid(myform)){
Virtuemart.sendtocart(jQuery(myform));
return false;
} else {return false;}
});
});
');
/* Required Custom Fields- End */



Around Line: 74.
Just below: echo JHTML::tooltip (vmText::_($field->custom_tip), vmText::_ ($field->custom_title), 'tooltip.png');

Add this code block. Including <?php and the closing ?>:
<?php
/* Required Custom Fields- Start */
JPluginHelper::importPlugin('system');
$dispatcher = JDispatcher::getInstance();
$results = $dispatcher->trigger( 'onDisplayCustomField', array(&$field) );
/* Required Custom Fields- End */
?>
User avatar
Fresh Boarder

teitbite
Wed Jul 02, 2014 11:27 am
Reply with quote
Report this post
Hi

Yes we have an override so this functionality was probably done differently, but nothing to worry. Please just take the file You will find in /components/com_virtuemart/views/productdetails/tmpl/default.php and install it over the one in /html/com_virtuemart/productdetails/defaut.php than You can make Your modifications to default_addtocart.php which should be located in the same directory.
User avatar
Moderator

GK User
Thu Jul 03, 2014 6:26 am
Reply with quote
Report this post
Use custom fields for all plugin by breakdesigns.net instead. Works so much better and gives you more options.
User avatar
Senior Boarder

GK User
Thu Jul 03, 2014 10:14 am
Reply with quote
Report this post
teitbite wrote:Hi

Yes we have an override so this functionality was probably done differently, but nothing to worry. Please just take the file You will find in /components/com_virtuemart/views/productdetails/tmpl/default.php and install it over the one in /html/com_virtuemart/productdetails/defaut.php than You can make Your modifications to default_addtocart.php which should be located in the same directory.



Thanks, it really worked, sad that we lost the good look, of the template...
User avatar
Fresh Boarder


cron