Custom fields

  • Posts: 102
  • Thank you received: 0
13 years 3 months ago #22571

so i tried then registering and i get a next button, but when i click next the only thing that happens is the form resets.

i could really use some help here.

Please Log in or Create an account to join the conversation.

  • Posts: 102
  • Thank you received: 0
13 years 3 months ago #22573

okay i uninstalled the cart, removed my view overrides etc... deleted the database and all the files and then reinstalled the whole thing again directly from the business download.
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.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 3 months ago #22605

Thank you for the research you did on the problem.
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
13 years 3 months ago #22608

THANK YOU!! that works!

Please Log in or Create an account to join the conversation.

  • Posts: 102
  • Thank you received: 0
13 years 3 months ago #22615

oops almost works

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.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 3 months ago #22616

You should do it differently. Instead of not showing at all the HTML of the custom field, you should still display it but add a style="dsiplay:none;" on the tr tag so that the custom field line is hidden. That should allow the JS handling the parent option to work properly.

Please Log in or Create an account to join the conversation.

  • Posts: 102
  • Thank you received: 0
13 years 3 months ago #22618

that could be a problem though: i need these fields to be required ... they are pickup date fields and i need them to not be passed through to the backend and cart as part of the order. wont that happen if they are there but not showing?

L

Please Log in or Create an account to join the conversation.

  • Posts: 102
  • Thank you received: 0
13 years 3 months ago #22625

okay trying it your way.
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

Last edit: 13 years 3 months ago by MinnieMouse. Reason: typos

Please Log in or Create an account to join the conversation.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 3 months ago #22626

It's indeed there. In the elementToCheck.className you should check if the class is dontValidate and return true;
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
13 years 3 months ago #22627

thinking about this the other way ... maybe it would be easier to use javascript on the the page to remove the required class from the hidden fields... hmmm

Please Log in or Create an account to join the conversation.

  • Posts: 102
  • Thank you received: 0
13 years 3 months ago #22628

i couldnt get that to work. i also am worried about tracking too many hacks to core files for updating...
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.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 3 months ago #22644

Well the custom fields system is indeed no made to handle it that way.
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
13 years 3 months ago #22665

okay good idea... what do i need to add exactly to which element to invoke the required script? i couldnt see any differences or classes that did that.

Please Log in or Create an account to join the conversation.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 3 months ago #22679

If you look on our demo website at the javascript of the checkout page, you can see that code:

var hikashop=Array();			
hikashop['reqFieldsComp']=Array();			
hikashop['validFieldsComp']=Array();
hikashop['reqFieldsComp']['register'] = Array('name','username','email','password','password2');
hikashop['validFieldsComp']['register'] = Array('Please enter a value for the field Name','Please enter a value for the field Username','Please enter a value for the field E-mail','Please enter a value for the field Password','Please enter a value for the field password2');									
hikashop['reqFieldsComp']['address'] = Array('address_title','address_firstname','address_lastname','address_street','address_city','address_telephone');					
hikashop['validFieldsComp']['address'] = Array('Please enter a value for the field Title','Please enter a value for the field First name','Please enter a value for the field Last name','Please enter a value for the field Street','Please enter a value for the field City','Please enter a value for the field Telephone');					
That code specifies which field is required. Since your fields are of the table order, you should add something like that:
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
13 years 3 months ago #22694

i did it. so i did it the first way i tried so that i didnt feed in the extra fields at all. i just added some code so that any field with a prefix of X would not be inserted. here it is:

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.

  • Posts: 209
  • Thank you received: 18
13 years 2 months ago #24745

Hi Nicolas, getting back to my original question at the start of this thread, I am still stuck on this...
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.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 2 months ago #24752

Hi,

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.

  • Posts: 34
  • Thank you received: 0
13 years 1 week ago #30178

I have version 1.5.3 on Joomla 1.7. I have added a custom field for an extra address line . I've published it everywhere, but for some reason the "Core" column remains unpublished and it won't let me publish it either - I can't even click on it. Is there any way to fix this problem?

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.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 1 week ago #30219

The "core" column is to say whether a custom field was in HikaShop by default or not (you can't delete them).
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.

Time to create page: 0.103 seconds
Powered by Kunena Forum