- Posts: 102
- Thank you received: 0
Custom fields
i could really use some help here.
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
i set up a few products and a payment zone etc..
i can then checkout.
then i added two custom fields each on the order table
parent field and child field.
parent field is a single drop down.
child is a single drop down with a limit to parent field on one of the options.
doesnt work. no errors and no javascript present.it lets me checkout but doesnt do the limited fields properly. does parent need to have some setting i am not seeing?
thanks, Liz
Please Log in or Create an account to join the conversation.
There was indeed some code missing to handle that option for custom fields of the type "order". We've published a new version which fixes the problem. You can download it again on our website and install over your current version to make it work.
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
it works with a straight usage of the template file however... if the parent doesnt appear at all the child is still appearing. i have my template working so that based on a custom field of product type it shows different parents. when the parent with the child does not appear. the child still appears. here is the code i have for my custom_fields view...
<?php
$mydates = 'default';
foreach($this->rows as $i => $row){
if (preg_match("/rosh/",$row->dates)) {
$mydates = "rosh";
}
//echo $row->dates;
}
//echo '-'.$mydates;
?>
<?php
if ($mydates =='rosh'){
$type = $this->type;
foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
if ($fieldName != 'default-dates'){; ?>
<tr class="hikashop_checkout_<?php echo $fieldName;?>_line" id="hikashop_<?php echo $type.'_'.$oneExtraField->field_namekey; ?>">
<td class="key">
<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
</td>
<td>
<?php $onWhat='onchange'; if($oneExtraField->field_type=='radio') $onWhat='onclick';
echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data',false,' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\'order\',0);"');
?>
</td>
</tr>
<?php } ?>
<?php } ?>
<?php
} else {
$type = $this->type;
foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
if ($fieldName != 'rosh-dates'){; ?>
<tr class="hikashop_checkout_<?php echo $fieldName;?>_line" id="hikashop_<?php echo $type.'_'.$oneExtraField->field_namekey; ?>">
<td class="key">
<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
</td>
<td>
<?php $onWhat='onchange'; if($oneExtraField->field_type=='radio') $onWhat='onclick';
echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data',false,' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\'order\',0);"');
?>
</td>
</tr>
<?php } ?>
<?php } ?>
<?php } ?>
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
L
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
i modified the script to add a class to hide the unwanted select, but then of course, it doesnt validate. so i added a class of dontValidate to the select that is hidden as well... now i am stuck with how to fix the validation to ignore a class of dontValidate invalid LOL
i think that is here (in hikashop.js.. any help with how to modify it?
function hikashopCheckField(elementToCheck,type,i,elementName,form){
if(elementToCheck){
var isValid = false;
if(typeof elementToCheck.value != 'undefined'){
if(elementToCheck.value==' ' && typeof form[elementName+'[]'] != 'undefined'){
if(form[elementName+'[]'].checked){
isValid = true;
}else{
for(var a=0; a < form[elementName+'[]'].length; a++){
if(form[elementName+'[]'][a].checked && form[elementName+'[]'][a].value.length>0) isValid = true;
}
}
}else{
if(elementToCheck.value.length>0) isValid = true;
}
}else{
for(var a=0; a < elementToCheck.length; a++){
if(elementToCheck[a].checked && elementToCheck[a].value.length>0) isValid = true;
}
}
if(!isValid){
elementToCheck.className = elementToCheck.className +' invalid';
alert(hikashop[type]);
return false;
}
}
return true;
}
Liz
Please Log in or Create an account to join the conversation.
However, there is a double check. One in javascript, and one server side. So you will also have to change the server check in the function _checkOneInput of the file administrator/components/com_hikashop/classes/field.php because otherwise, the system won't accept the data.
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
what do you think the best way to do this would be?
one select list of dates and one set of hours needs to appear as default.
then there are items which call an override select which is a parent to a number of child hours lists...
they all need to be required.
furthermore another weird thing that happens is that when you click next after all the filling of the first page... you click next and it takes you to another page where it resets the select lists and you have to fill them in again... which is not really great. why is that?
thanks, Liz
Please Log in or Create an account to join the conversation.
One solution which might be better is to not set the field as required in the options of the field, but to add it on the fly with javascript on page load and add/remove it based on the selection of the user.
That wouldn't produce any hack of core files and that seems like a lighter solution.
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
Please Log in or Create an account to join the conversation.
hikashop = Array('my_custom_field_column');
hikashop = Array('Please enter a value for the field My field');
Or then remove these arrays when needed via some javascript.
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
thanks for all the help!!!
<?php
$searchterm = 'rosh'; //the special holiday menu that overrides the default entertainment menu. this value should be the same as the value in the dates type select at the bottom of a product.
$mydates = 'default';
foreach($this->rows as $i => $row){
//$row->dates is the value that is retrieved from the cart products custom field dates.
if (preg_match("/$searchterm/",$row->dates)) {
$mydates = $searchterm;
}
}
?>
<?php
if ($mydates == $searchterm){
$type = $this->type;
foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
if ($fieldName != 'default-dates'){; ?>
<tr class="hikashop_checkout_<?php echo $fieldName;?>_line" id="hikashop_<?php echo $type.'_'.$oneExtraField->field_namekey; ?>">
<td class="key">
<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
</td>
<td>
<?php $onWhat='onchange'; if($oneExtraField->field_type=='radio') $onWhat='onclick';
echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data',false,' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\'order\',0);"');
?>
</td>
</tr>
<?php } ?>
<?php } ?>
<?php
} else {
$type = $this->type;
foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
if (!preg_match("/$searchterm/",$fieldName)){; ?>
<tr class="hikashop_checkout_<?php echo $fieldName;?>_line" id="hikashop_<?php echo $type.'_'.$oneExtraField->field_namekey; ?>">
<td class="key">
<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
</td>
<td>
<?php $onWhat='onchange'; if($oneExtraField->field_type=='radio') $onWhat='onclick';
echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data',false,' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\'order\',0);"');
?>
</td>
</tr>
<?php } ?>
<?php } ?>
<?php } ?>
Please Log in or Create an account to join the conversation.
I'm using Essentials 1.5.3.
I need to get more information from the customer depending on what product they are buying.
For example:
If they buy a product from Category A, I also need to know their birthdate
If they buy a product from Category B, I also need to know their drivers licence number but not their birthdate
To which you replied...
Category custom fields are only to add information to categories. You won't be able to do what you want with them.
You should wait for next release (before the end of the week) as it includes new options for custom fields which will allow you to display them only for some categories. That way, you will be able to create custom fields of the table "item" and restrict them to category A or B.
So now I've got the latest release but I can't see where I can create a custom field of the table "item" as you describe or how to restrict a field to a category.
Thanks.
Please Log in or Create an account to join the conversation.
Custom fields of the table "item" are only available in the Business edition. That's why you don't see them.
Please Log in or Create an account to join the conversation.
I'm assuming this is why it's entered but not saved on the client end.
Please Log in or Create an account to join the conversation.
So it's normal that you can't change it and it has no incidence on the behavior of the custom field.
If the custom field doesn't get the value entered, it comes from something else. You should activate the debug mode in the configuration of joomla and try again to see if you get an error message. If no, please give a link to that page so that we can have a look.
Please Log in or Create an account to join the conversation.