VM Custom fields issue

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
Tue Apr 15, 2014 6:49 pm
Reply with quote
Report this post
Hello Guys!
Could you help me please. I spend a few days trying to find solution, but didn’t succeed and my brain is exploding.
So the problem is: I’m trying to make apparel store. Have Joomla 2.5.19 with Virtuemart 2.0.26d installed. On product detail page I have custom field (select list, cart variant) called SIZE. This custom field has options: Small, Medium, Large etc., but also it has first (top) option = “Please select”.
I want this custom field to be required for select (mandatory) before you’ll be able to add item to cart. For example if shop customer didn’t select size (left custom field option as “Please select”) and pressed add to cart button, he will see alert massage ( <script type="text/javascript"> alert(“Please select size first”); </script> ) and product will not be added to cart until you select size.
Have you any idea what and where I have to change? I’m new in Joomla, Virtuemart and PHP. I was searching on different forums but couldn’t find exactly what I need.
Will appreciate for any help coz I’m stuck on this in my project.
User avatar
Fresh Boarder

GK User
Thu Apr 17, 2014 8:14 am
Reply with quote
Report this post
Probably the easiest solution is to just add this code to existing template javascript, the main script is located in template/js/gk.script.js and if you add your code there it will be included in all pages including VirtueMart views.
User avatar
Platinum Boarder

GK User
Fri Apr 18, 2014 2:33 pm
Reply with quote
Report this post
I think I have to get value of custom field, value that currently selected and add some code in cart.php (components\com_virtuemart\controllers) in public function addJS() that is responsible for adding items to cart.
Something like that:

public function addJS() {
$selectedValue = //here should be code of obtaining custom field selected value
if($selectedValue==”Please select”){
<script type="text/javascript"> alert(“Please select size first”); </script>
}
else{
//execute code of the function

}

Do you have any idea how to get selected value of VM2 custom field?
User avatar
Fresh Boarder

GK User
Tue Apr 22, 2014 9:42 am
Reply with quote
Report this post
If you use jQuery the code will look like :

Code: Select all
jQuery('#idOffield').val();
User avatar
Platinum Boarder

GK User
Mon May 26, 2014 12:28 am
Reply with quote
Report this post
Did you ever get the custom field validation working?
User avatar
Senior Boarder

GK User
Tue May 27, 2014 8:17 am
Reply with quote
Report this post
Create own validation rules is probably the only way validate additional/custom fields in VirtueMart.
User avatar
Platinum Boarder


cron