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

How to cancel mandatory (required) field in Virtuemart form submission process?

Started by papakota, January 22, 2020, 03:16:36 AM

Previous topic - Next topic

papakota

Hello
I want to free my future site's visitors from having to fill out the form before submitting their name, e-mail and a phone No. Basically, in most cases it won't be needed for them to also add more information in the form's text box. But the default (current) status is that they must at least type a single word before they're allowed to submit the form. I'll attach screenshot to better clarify the issue and also provide a link to a live site where you can see it in a real life situation.

https://www.profilecreations.co.za/index.php/products/desktop-stationery/blockpads/pvc-blockpad-detail

It's a Joomla's Virtuemart shop. Latest Joomla version and VM3 working together. In a product detail page there's an "Ask A Question" button. After it's clicked, you get a contact form, in which one can input their contact info and fill out the text box below and press "Send your question" button just below. My goal is just to directly contact the potential client by using their e-mail or a phone number. I don't need them to necessarily provide me with more information in that text box rectangle.  What I know so far is that there's a Virtuemart controller PHP file that makes sure that the required text box is filled out before the form's submission. This one: components/com_virtuemart/controllers/productdetails.php I'll also attach it to this post (tgziped). It must be modified so that there wouldn't be a requirement of filling out that text box befere one can submit the form. Here's the link to the real live site's product detail page with an "Ask A Question" button in the middle.

Jörgen

The min and max nr of characters can be set in VM back end configuration shop front. But setting it to 0 and 0 does not seem work. I am not using the latest version of VM. You could alway try to set number of characters to 0 and 0.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

papakota

Nope, it doesn't work also in the lastest version. The issue is that the filling out the form is required. Regardless of number of characters that I can set in VM's backend.

GJC Web Design

override the components\com_virtuemart\views\recommend\tmpl\form.php and adapt as required
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

papakota

GJC Web Design,
So what exactly should I change in that file to achieve my goal?

jenkinhill

Setting Question minimum length in VM Configuration/Shopfront to  -1  allows the form to submit with no content.

To tidy the user interface edit and override the file described by GJC - only a case of removing two table rows.

You could change the text on the submit button with a language override of COM_VIRTUEMART_ASK_SUBMIT
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

papakota

I've set minimum question length to -1, but I still can't submit the form without writing something in it.
As per that file that GJC Web Design mentioned... Editing it will solve my issue? If YES, then what exactly should be changed in it?

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

jenkinhill

And if you are using template overrides already then the file to edit may be templates/[your joomla template]/html/com_virtuemart/recommend/form.php  -  this is also where your edited file should be placed if not already there.
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

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

papakota

GJC Web Design,
class="validate[required,minSize[<?php echo $min ?>],maxSize[<?php echo $max ?>]] field"
I deleted this code in that file, but nothing's changed. You said that I had to remove a validation class...

GJC Web Design

keep trying till you find it.. the idea of this forum is not "get my development work done for free"...
It is to receive advice... I have no idea "exactly" how to disable the validation because i have never needed to do it... but it will be there somewhere
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

Add a simple point as value for eg. So you have something by default in the form

papakota

I've figured out myself how to solve the issue. First of all, I got rid of the text box and a character counter altogether in file:components/com_virtuemart/views/askquestion/tmpl/form.php
Then I solved the character validation issue in file: components/com_virtuemart/controllers/productdetails.php like so:

$min = VmConfig::get ('asks_minimum_comment_length', 0) - 1;

In the end, I just get the form with NAME, E-MAIL, PHONE NO. and a captcha validation.
I'll attach a targzipped versions of both edited files in case anyone needs something like this.