Custom fields

  • Posts: 209
  • Thank you received: 18
13 years 4 months ago #22070

Hi,

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.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 4 months ago #22078

Hi,

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
13 years 3 months ago #22478

I just purchased the business version today, but i think i need this feature. is this in the current release or still not out yet?

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.

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

It is out yes. You can now limit a custom field to only one group of products. That way you could ask a pickup date for each product with different values based on the type of product.

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
13 years 3 months ago #22481

okay so i was playing with that. but i really am selling food items not pets (pets made it easier to describe the issue, but i see now ... too simple). i made an item drop list with my dates... but that shows on every product. i want it to only display in the address / checkout portion of the shopping.
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!

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

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

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

Well, fields of the order table are for the whole order, so there can't be any category restriction on them.
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
13 years 3 months ago #22484

hi nicolas, yes, i was trying to minimize the amount of "hacking" i needed to do by using whatever was built in first.

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

Last edit: 13 years 3 months ago by MinnieMouse.

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

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

The categories of the products are not loaded on the checkout as they are not used for anything. You would have to do the mysql query yourself and then based on the categories of the products, display one custom field or the other or something like that.

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

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

also, how do i access the cart values?

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

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

Like that for example:

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
13 years 3 months ago #22490

thanks! wasnt sure this was available that easily. okay i am now going to see if i can get this to work. i will probably have more questions. LOL


Liz

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

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

So i did this:

<?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.

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

The code
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
13 years 3 months ago #22515

thanks nicolas, i think i got it working.

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

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

now another question though. so i created a select list that is limited to one of the above lists. i assumed that meant that it would be an ajax list that would only show when a specific option on the other is selected. that is not working. do i misunderstand the use of the limit to... or is there something else i need to do to make it work.

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 #22521

No you're correct. The custom field will be displayed or not automatically based on the other one value. If it doesn't work maybe it's because you updated from a previous version of HikaShop and you still have the javascript files cached by your browser. Or you have edited a view before updating and you don't have the new code necessary in the view to make it work. Or you have some javascript errors on your page.

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

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

i upgraded from installing a free version last week, i had not altered anything in the views. i will look for a javascript error. is hika running on jquery or mootools?

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

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

which version of mootools should i be using 1.1 or 1.2 upgrade? no javascript errors apparent using firebug. my view is just altered to show or not show a date list based on product type in the cart but the loop of custom fields is intact with the html intact...

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

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

okay so looking at your hikashop.js you are calling a noconflict jquery ... there is no jquery loaded in my site. SHOULD THERE BE?
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...

Last edit: 13 years 3 months ago by MinnieMouse.

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

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

in my continuing monologue :-)...
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?

Last edit: 13 years 3 months ago by MinnieMouse.

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

Time to create page: 0.096 seconds
Powered by Kunena Forum