Wytas Posted June 5, 2016 Share Posted June 5, 2016 Hello, I have this problem. When writing a product review one of the required fields is "Title". I tried modifying productcomments.tpl in themes/default-bootstrap/modules/productcomments and was able to remove title from new review page but still when I test by writing "Your name", "Comment" in two fields that have left and submiting it, it still says "Title is incorrect". So something still requires the title to entered even tho it isn't shown in the page anymore. What else do I need to modify? Link to comment Share on other sites More sharing options...
rocky Posted June 6, 2016 Share Posted June 6, 2016 It's the following code on lines 77-78 (in PrestaShop v1.6.1.5) of modules/productcomments/controllers/front/default.php that displays that error message: if (!Tools::getValue('title') || !Validate::isGenericName(Tools::getValue('title'))) $errors[] = $module_instance->l('Title is incorrect', 'default'); I suggest that you // comment out those lines. 2 Link to comment Share on other sites More sharing options...
Wytas Posted June 6, 2016 Author Share Posted June 6, 2016 Thanks a lot man it worked. Maybe you can also tell me why the name that you enter in review page does not overide name that was entered in shipping details and saved in cookies? If you write different name comment still saves with name and first letter of a surname. How can I change this? Link to comment Share on other sites More sharing options...
rocky Posted June 7, 2016 Share Posted June 7, 2016 I read the code and it appears to be lines 109-111 (in PrestaShop v1.6.1.5) of modules/productcomments/ProductComment.php that overrides the comment name with the customer name: IF(c.id_customer, CONCAT(c.`firstname`, \' \', LEFT(c.`lastname`, 1)), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pc.title FROM `'._DB_PREFIX_.'product_comment` pc LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = pc.`id_customer` Try changing it to the following: pc.customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pc.title FROM `'._DB_PREFIX_.'product_comment` pc I haven't tested this code, so you'll have to test it for me. 1 Link to comment Share on other sites More sharing options...
Wytas Posted June 7, 2016 Author Share Posted June 7, 2016 (edited) Okay I tested it and it works. Appreciate it. But one more question because I am green at php coding. Now when you don't enter any name (like before) comment saves with customer name instead of giving an error that name is incorrect and that is good, but before it was saving name and first letter of a surname of a customer, now it saves name and full surname. I would prefer it would be like it was before. Any thoughts? Edited June 7, 2016 by wyttazs (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted June 7, 2016 Share Posted June 7, 2016 I found the following on line 104-105 (in PrestaShop v1.6.1.5) of modules/productcomments/controllers/front/default.php that appears to do that: if (!$comment->customer_name) $comment->customer_name = pSQL($this->context->customer->firstname.' '.$this->context->customer->lastname); Try changing it to: if (!$comment->customer_name) $comment->customer_name = pSQL($this->context->customer->firstname.' '.Tools::substr($this->context->customer->lastname, 0, 1).'.'); This should change the name from John Doe to John D. 1 Link to comment Share on other sites More sharing options...
Wytas Posted June 7, 2016 Author Share Posted June 7, 2016 It worked. Thanks a lot dude. Wouldn't have managed all this by myself. You are the best. And I thought that those lines in modules/productcomments/ProductComment.php that I changed were doing this, because it was "John D" before changing them. 1 Link to comment Share on other sites More sharing options...
maraguta Posted April 4, 2017 Share Posted April 4, 2017 Hi. Can You tell me how should I modify the code for submit this form with no need to write name? I want to have only rting stars(Quality:) recquired. I comment out lines.77, 78 concerning 'titile' but doing the same in field 'content' it doesnt work. And field 'customer_name' is connected with Submit so i dont know how to separete it. $errors = array(); // Validation if (!Validate::isInt(Tools::getValue('id_product'))) $errors[] = $module_instance->l('Product ID is incorrect', 'default'); //if (!Tools::getValue('title') || !Validate::isGenericName(Tools::getValue('title'))) //$errors[] = $module_instance->l('Title is incorrect', 'default'); //if (!Tools::getValue('content') || !Validate::isMessage(Tools::getValue('content'))) //$errors[] = $module_instance->l('Comment is incorrect', 'default'); if (!$id_customer && (!Tools::isSubmit('customer_name') || !Tools::getValue('customer_name') || !Validate::isGenericName(Tools::getValue('customer_name')))) $errors[] = $module_instance->l('Customer name is incorrect', 'default'); if (!$this->context->customer->id && !Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS')) $errors[] = $module_instance->l('You must be connected in order to send a comment', 'default'); if (!count(Tools::getValue('criterion'))) $errors[] = $module_instance->l('You must give a rating', 'default'); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now