News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Function disabled

Started by jorgepracticum, October 14, 2015, 18:12:48 PM

Previous topic - Next topic

jorgepracticum

Hi
When im trying to send a email for "Call for price" I click that button, a popup appeared, I fill the gaps and press Send
But the popup sais me this message:
QuoteFunction disabled
I supouse that this mean that my email function is not aviable. But I tried the three send mail server that i can configure in Joomla and it doesn't work
How can i solve it?
I'm using Joomla 3.4.4 and VM 3
Regards

jenkinhill

Are you on a real server or on localhost? What VM version?
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

jorgepracticum

I have just edited the first post with my VM version, which is version 3
I'm a localhost, but with other joomla components i can send mails with a SMTP server (thats the server that i have configured in Joomla configuration)

jorgepracticum

Hi
I've just discoverd in what file the component send the mail and where is the error message
The file is:
Quotecomponents/com_virtuemart/controllers/productdetails.php
And the code that show the message is:
public function mailAskquestion () {

                JSession::checkToken () or jexit ('Invalid Token');

                $app = JFactory::getApplication ();
               
                /*if(!VmConfig::get('ask_question',false)){
                        $app->redirect (JRoute::_ ('index.php?option=com_virtuemart&tmpl=component&view=productdetails&task=askquestion&virtuemart_product_id=' . vRequest::getInt ('virtuemart_product_id', 0)), 'Function disabled');
                }*/

                $view = $this->getView ('askquestion', 'html');
                if (!class_exists ('shopFunctionsF')) {
                        require(VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
                }

                $vars = array();
                $min = VmConfig::get ('asks_minimum_comment_length', 50) + 1;
                $max = VmConfig::get ('asks_maximum_comment_length', 2000) - 1;
                $commentSize = vRequest::getString ('comment');
                if (function_exists('mb_strlen')) {
                        $commentSize =  mb_strlen($commentSize);
                } else {
                        $commentSize =  strlen($commentSize);
                }

                $validMail = filter_var (vRequest::getVar ('email'), FILTER_VALIDATE_EMAIL);

                if ($commentSize < $min or $commentSize > $max or !$validMail) {
                        $errmsg = vmText::_ ('COM_VIRTUEMART_COMMENT_NOT_VALID_JS');
                        if ($commentSize < $min) {
                                $errmsg = vmText::_ ('COM_VIRTUEMART_ASKQU_CS_MIN');

                        } else {
                                if ($commentSize > $max) {
                                        $errmsg = vmText::_ ('COM_VIRTUEMART_ASKQU_CS_MAX');

                                } else {
                                        if (!$validMail) {
                                                $errmsg = vmText::_ ('COM_VIRTUEMART_ASKQU_INV_MAIL');

                                        }
                                }
                        }

                        $this->setRedirect (JRoute::_ ('index.php?option=com_virtuemart&tmpl=component&view=productdetails&task=askquestion&virtuemart_product_id=' . vRequest::getInt ('virtuemart_product_id', 0)), $errmsg);
                        return;
                }

                if(JFactory::getUser()->guest == 1 and VmConfig::get ('ask_captcha')){
                        $recaptcha = vRequest::getVar ('recaptcha_response_field');
                        JPluginHelper::importPlugin('captcha');
                        $dispatcher = JDispatcher::getInstance();
                        $res = $dispatcher->trigger('onCheckAnswer',$recaptcha);
                        $session = JFactory::getSession();
                        if(!$res[0]){
                                $askquestionform = array('name' => vRequest::getVar ('name'), 'email' => vRequest::getVar ('email'), 'comment' => vRequest::getString ('comment'));
                                $session->set('askquestion', $askquestionform, 'vm');
                                $errmsg = vmText::_('PLG_RECAPTCHA_ERROR_INCORRECT_CAPTCHA_SOL');
                                $this->setRedirect (JRoute::_ ('index.php?option=com_virtuemart&tmpl=component&view=productdetails&task=askquestion&virtuemart_product_id=' . vRequest::getInt ('virtuemart_product_id', 0)), $errmsg);
                                return;
                        } else {
                                $session->set('askquestion', 0, 'vm');
                        }
                }

                $user = JFactory::getUser ();
                if (empty($user->id)) {
                        $fromMail = vRequest::getVar ('email'); //is sanitized then
                        $fromName = vRequest::getVar ('name', ''); //is sanitized then
                        $fromMail = str_replace (array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $fromMail);
                        $fromName = str_replace (array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $fromName);
                } else {
                        $fromMail = $user->email;
                        $fromName = $user->name;
                }
                $vars['user'] = array('name' => $fromName, 'email' => $fromMail);

                $virtuemart_product_id = vRequest::getInt ('virtuemart_product_id', 0);
                $productModel = VmModel::getModel ('product');

                $vars['product'] = $productModel->getProduct ($virtuemart_product_id);

                $vendorModel = VmModel::getModel ('vendor');
                $VendorEmail = $vendorModel->getVendorEmail ($vars['product']->virtuemart_vendor_id);

                JPluginHelper::importPlugin ('system');
                JPluginHelper::importPlugin ('vmextended');
                JPluginHelper::importPlugin ('userfield');
                $dispatcher = JDispatcher::getInstance ();
                $dispatcher->trigger ('plgVmOnAskQuestion', array(&$VendorEmail, &$vars, &$view));

                $vars['vendor'] = array('vendor_store_name' => $fromName);

                if (shopFunctionsF::renderMail ('askquestion', $VendorEmail, $vars, 'productdetails',true)) {
                        $string = 'COM_VIRTUEMART_MAIL_SEND_SUCCESSFULLY';
                } else {
                        $string = 'COM_VIRTUEMART_MAIL_NOT_SEND_SUCCESSFULLY';
                }
                $app->enqueueMessage (vmText::_ ($string));


                $view->setLayout ('mail_confirmed');
                $view->display ();
        }

The "IF" structure commented is where the code show my error message
If I comment that IF, the code works properly and it sends the email...
So why the component show me the message if the email can be send properly?

jorgepracticum

Well, I solved my problem
In the backend configuration I have to enable the option "Allow ask questions"
I didn't think that this option must be enable for ask for price. But enabling it solved my problem
Regards