VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: cynthu on April 13, 2012, 04:57:10 AM

Title: Supress Minimun character validation in "Ask a question about this product?"
Post by: cynthu on April 13, 2012, 04:57:10 AM
How can I remove the Min. Char validation in "Ask a question about this product?" Thanks!

Here is the code:

<?php
/**
 *TODO Improve the CSS , ADD CATCHA ?
 * Show the form Ask a Question
 *
 * @package VirtueMart
 * @subpackage
 * @author Kohl Patrick
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 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 2810 2011-03-02 19:08:24Z Milbo $
 */

// Check to ensure this file is included in Joomla!
defined '_JEXEC' ) or die ( 'Restricted access' );
$min VmConfig::get('vm_asks_minimum_comment_length'50);
$max VmConfig::get('vm_asks_maximum_comment_length'5000) ;
vmJsApi::JvalideForm();
$document JFactory::getDocument();
// $document->addScript(JURI::root(true).'/components/com_virtuemart/assets/js/jquery.validation.js');
$document->addScriptDeclaration('
jQuery(function($){
$("#askform").validationEngine("attach");
$("#comment").keyup( function () {
var result = $(this).val();
$("#counter").val( result.length );
});
});
'
);
/* Let's see if we found the product */
if (empty ( $this->product )) {
echo JText::'COM_VIRTUEMART_PRODUCT_NOT_FOUND' );
echo '<br /><br />  ' $this->continue_link_html;
} else { 
?>


<div class="ask-a-question-view">
<h1><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ASK_QUESTION')  ?></h1>

<div class="product-summary">
<div class="width70 floatleft">
<h2><?php echo $this->product->product_name ?></h2>

<?php // Product Short Description
if (!empty($this->product->product_s_desc)) { ?>

<div class="short-description">
<?php echo $this->product->product_s_desc ?>
</div>
<?php // Product Short Description END ?>

</div>

<div class="width30 floatleft center">
<?php // Product Image
echo $this->product->images[0]->displayMediaThumb('class="product-image"',false); ?>

</div>

<div class="clear"></div>
</div>

<?php // Get User
if (!empty($this->user->id)) {
$user JFactory::getUser();
?>


<div class="form-field">

<form method="post" class="form-validate" action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$this->product->virtuemart_product_id.'&virtuemart_category_id='.$this->product->virtuemart_category_id.'&tmpl=component') ; ?>" name="askform" id="askform">

<label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_NAME')  ?> : <input type="text" class="validate[required,minSize[4],maxSize[64]]" value="<?php echo $this->user->name ?>" name="name" id="name" size="30"  validation="required name"/></label>
<br />
<label><?php echo JText::_('COM_VIRTUEMART_USER_FORM_EMAIL')  ?> : <input type="text" name="email" id="email" size="30"  validation="required email"/></label>
<br/>
<label>
<?php
$ask_comment JText::sprintf('COM_VIRTUEMART_ASK_COMMENT'$min$max);
echo $ask_comment;
?>

<br />
<textarea title="<?php echo $ask_comment ?>" class="validate[required,minSize[<?php echo $min ?>],maxSize[<?php echo $max ?>]] field" id="comment" name="comment" rows="10"></textarea>
</label>
<div class="submit">
<input class="highlight-button" type="submit" name="submit_ask" title="<?php echo JText::_('COM_VIRTUEMART_ASK_SUBMIT')  ?>" value="<?php echo JText::_('COM_VIRTUEMART_ASK_SUBMIT')  ?>" />

<div class="width50 floatright right paddingtop">
<?php echo JText::_('COM_VIRTUEMART_ASK_COUNT')  ?>
<input type="text" value="0" size="4" class="counter" ID="counter" name="counter" maxlength="4" readonly="readonly" />
</div>
</div>

<input type="hidden" name="cid[]" value="<?php echo JRequest::getInt('virtuemart_product_id',0); ?>" />
<input type="hidden" name="virtuemart_product_id" value="<?php echo JRequest::getInt('virtuemart_product_id',0); ?>" />
<input type="hidden" name="tmpl" value="component" />
<input type="hidden" name="view" value="productdetails" />
<input type="hidden" name="option" value="com_virtuemart" />
<input type="hidden" name="virtuemart_category_id" value="<?php echo JRequest::getInt('virtuemart_category_id'); ?>" />
<input type="hidden" name="task" value="mailAskquestion" />
<?php echo JHTML::_'form.token' ); ?>
</form>

</div>

</div>

<?php ?>
Title: Re: Supress Minimun character validation in "Ask a question about this product?"
Post by: Studio 42 on April 13, 2012, 08:22:10 AM
We simply forgot the setting in the configuration of virtuemart.
Added for next release.
Title: Re: Supress Minimun character validation in "Ask a question about this product?"
Post by: cynthu on April 13, 2012, 15:01:59 PM
Thanks, but isn't there a way to bypass this, because even though I set the Min. comment length to 0, you can't send the e-mail until you have written 50 chraracters.
Also, is there a code I can add so symbols are sent?

Thanks!
Title: Re: Supress Minimun character validation in "Ask a question about this product?"
Post by: Vian on April 18, 2012, 15:56:29 PM
Hi there, I'm experiencing the same issue.

I noticed the changes on the last release, changing vm_asks_minimum_comment_length to  asks_minimum_comment_length, samething with the max lenght, but nothing was done about the validation right? Tried to change the minimun value from 50 to 0, but the validation still requires 50characters in order to accept the form.

thanks
Title: Re: Supress Minimun character validation in "Ask a question about this product?"
Post by: murenti on May 14, 2012, 02:26:53 AM
I would appreciate the solution to this also please.

Your help is much appreciated
Title: Sol Supress Minimun character validation in "Ask a question about this product?"
Post by: antonino78 on June 14, 2012, 15:35:23 PM
hello,
if I go to change configuration / shop front end text values ​​for the minimum and maximum length in the front end does not work.
Changes only the display of the product but the request is not sent because the values ​​are tapped at 50 characters minimum and maximum 1000 characters :-\
version 2.07e
SOLVED :)
Title: Re: Supress Minimun character validation in "Ask a question about this product?"
Post by: dudu30 on September 20, 2012, 13:06:18 PM
For a minimum of 3 characters :

- edit : components/com_virtuemart/views/askquestion/tmpl/form.php

- comment the line "echo $ask_comment" like this:
<?php
       $ask_comment = JText::sprintf('COM_VIRTUEMART_ASK_COMMENT', $min, $max);
         //echo $ask_comment;
   ?>

- modify the line who begins with <textarea like this:
<textarea title="<?php echo $ask_comment ?>" class="validate[required,minSize[3],maxSize[<?php echo $max ?>]]

- edit : components/com_virtuemart/controllers/productdetails.php

change the code like this:

                if ($commentSize > $max or !$validMail) {
                        $errmsg = JText::_ ('COM_VIRTUEMART_COMMENT_NOT_VALID_JS');
                                if ($commentSize > $max) {
                                        $errmsg = JText::_ ('COM_VIRTUEMART_ASKQU_CS_MAX');
                                        ;
                                } else {
                                        if (!$validMail) {
                                                $errmsg = JText::_ ('COM_VIRTUEMART_ASKQU_INV_MAIL');
                                                ;
                                        }

                        }

                        $this->setRedirect (JRoute::_ ('index.php?option=com_virtuemart&tmpl=component&view=productdetails&task=askquestion&virtuemart$
                        return;
                }

That's it!

enjoy ;)

Title: Re: Supress Minimun character validation in "Ask a question about this product?"
Post by: jenkinhill on September 20, 2012, 15:14:14 PM
No need for that, as it is now in configuration:
Question minimum length  and  Question maximum length
Title: Re: Supress Minimun character validation in "Ask a question about this product?"
Post by: cmb on October 11, 2012, 00:16:24 AM
Quote from: jenkinhill on September 20, 2012, 15:14:14 PM
No need for that, as it is now in configuration:
Question minimum length  and  Question maximum length
For anyone coming to this thread looking for a solution, here's the path to the settings:
Administrator > Components > VirtueMart > Configuration > Configuration (again, if necessary) > Shopfront tab > Core Settings.

VirtueMart 2.0.12b