- Posts: 209
- Thank you received: 18
Custom fields
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
I have tried creating a custom "Category" field but I can't see how to link this just to a particular category of products nor can I get it to show anywhere in the front end, either on the product page or the registration page.
After creating the custom category fields, I can see them when I edit the category details but can't seem to turn some off for a particular category.
Any help appreciated!
Please Log in or Create an account to join the conversation.
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.
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
also, this is what i want to do with it, please tell me if its possible.
we have categories {cat, dog fish}
we do pick up in our store. you order a dog and pick it up (just an example). so if you order a dog you get one set of pick up dates. if you order a cat you get a different set of pick up dates. (so the dogs and cats dont fight) if you order a fish you can pick it up on default set of pick up dates.
is this possible with your new feature?
thanks, Liz
Please Log in or Create an account to join the conversation.
Note that you should create custom fields of the table "item" via the menu Display->Custom fields.
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
say you have
cat: dairy
cat: meat
prod: dairy: cheese
prod: dairy: cream
prod: meat: salami
i order one of each item of cheese and cream. i dont want to have to have the customer specify the pickup date on both those items but rather in the cart it sees that there is dairy in the cart and gives them the specific droplist associated with dairy category.
is that possible?
it looks like the field table i want is the "order" table. then i want to be able to say.. this field in the order table only displays if this category is displayed.
thanks for the help!
Please Log in or Create an account to join the conversation.
If you want a custom field for cheese and and another one for salami, what if you have both a salami and a cheese in the cart ? Should both be displayed ? Or none ? From what I understand you would like both.
But that kind of limitation is hard to do automatically. You'll have to customize the custom_fields file of the view checkout via the menu Display->Views in order to display or not the different custom fields based on the type of the product (You could create a custom field of the table "product" in order to select the type of the product for each of your products so that you could more easily loop through the products of the cart and display or not custom order fields). That will require some coding...
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
so the idea was one default table of dates that all can use. then if there are any special items in the cart this table of pick up dates overrides the default. i dont have to worry about two separate categories being ordered together because the dates are different enough over time. (hard to really explain). all i really need is one default set and one override set based on the category of items represented in the cart.
from what you are saying below i have a question..
you say "You'll have to customize the custom_fields file of the view checkout via the menu Display->Views in order to display or not the different custom fields based on the type of the product"
does this mean from that view i could not retrieve the category of the product and use that?
also, how do i access the cart values?
thanks, Liz
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
Please Log in or Create an account to join the conversation.
foreach($this->rows as $i => $row){
echo $row->product_id;
}
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
Liz
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
<?php
foreach($this->rows as $i => $row){
echo $row->dates;
}
if (strstr($row->dates,'default')){
$type = $this->type;
foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
?>
<tr class="hikashop_checkout_<?php echo $fieldName;?>_line">
<td class="key">
<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
</td>
<td>
<?php
echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data');
?>
</td>
</tr>
<?php } ?>
<?php } ?>
dates is my table field it has two values right now. one of which is default.
i have a product with a field defined with that value. and the echo spits out defaultdefault with two items in my cart which is correct. but for some reason... the if throws a negative.
any help would be appreciated!
thanks, Liz
Please Log in or Create an account to join the conversation.
if (strstr($row->dates,'default')){
is outside the foreach loop so that's normal it doesn't work.
you should rather do something like that:
$found = false;
foreach($this->rows as $i => $row){
if ($row->dates=='default') $found = true;
}
if($found){
...
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
thanks, Liz
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
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
thanks!
liz
[edit] upon further examination... i think you are checking for jquery and providing a no conflict mode if it exists for some other reason on the site...
Please Log in or Create an account to join the conversation.
- Posts: 102
- Thank you received: 0
there appears to be no javascript controlls or functions that i can find that would cause the behavior to happen. what am i missing?
Liz
[edit]
so the function hikashopToggleFields is not appearing on my custom fields where it should be. a look in the files revealed this:
the file form_fields.php has the following code for toggling:
<?php foreach($this->extraFields as $fieldName => $oneExtraField) { ?>
<tr id="hikashop_entry_<?php echo $fieldName.'_'.$this->id;?>" class="hikashop_entry_<?php echo $fieldName;?>">
<td class="key">
<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
</td>
<td>
<?php echo $this->fieldsClass->display($oneExtraField,$this->entry->$fieldName,'data[entry][entry_'.$this->id.']',false,' onchange="hikashopToggleFields(this.value,\''.$fieldName.'\',\'entry\','.$this->id.');"'); ?>
</td>
</tr>
<?php }?>
however my base template looks like this for custom fields:
<?php
$type = $this->type;
foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
?>
<tr class="hikashop_checkout_<?php echo $fieldName;?>_line">
<td class="key">
<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
</td>
<td>
<?php
echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data');
?>
</td>
</tr>
<?php } ?>
shouldnt there be some language about if the field is limited and applying the toggle function and javascript?? where does this occur and why is it not occurring on my fields?
Please Log in or Create an account to join the conversation.