Custom fields on product page

  • Posts: 8
  • Thank you received: 0
13 years 17 hours ago #31106

Hi.
I use the business edition. I have added a custom field to some of the shops products, and i am now having trouble seeing the input data from these fields.
Further more i want to add the input to the confirmation email and the admin mail.

Like this:


Item_________________Quantity________Price________Total
Nokia 3310__________62______________210$_______13.200,-
Name: SAM {Costum field info}

Nokia 6210__________2_______________280$________560,-
Name: SAM {Costum field info}


I'm new to php, so i haven't been able to do this by myself:(

Last edit: 13 years 17 hours ago by pamolade.

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 13 hours ago #31116

Hi,

First, you need to edit your emails vi the menu System->Emails, there, you can do like that:
<?php
$productClass = hikashop_get('class.product');
$product = $productClass->get($item->product_id);
echo $product->CUSTOM_FIELD_COLUMN_NAME; ?>

Don't forget to replace CUSTOM_FIELD_COLUMN_NAME by the column name of your custom field.

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

  • Posts: 8
  • Thank you received: 0
12 years 11 months ago #31193

Whats second? Because this didn't work :(

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
12 years 11 months ago #31221

There is actually no second :p

That's all you need to do but make sure that you add that code inside of the foreach which loops through the products of the order. Like that for example:
foreach($data->cart->products as $item){
?>
<tr>
<td>
<?php
$productClass = hikashop_get('class.product');
$product = $productClass->get($item->product_id);
echo $product->CUSTOM_FIELD_COLUMN_NAME; ?>

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

  • Posts: 8
  • Thank you received: 0
12 years 11 months ago #31287

Sorry, but I'm not that experienced in php.. I haven't made any other changes in the php, so this is the only need i have.
Would you be kind to send me the complete email with the text from above? My custom field name is: mereinfo

In advance, Thanks!

Last edit: 12 years 11 months ago by pamolade.

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
12 years 11 months ago #31297

In your email,

replace the code:
foreach($data->cart->products as $item){
?>
<tr>
<td>

by:
foreach($data->cart->products as $item){
?>
<tr>
<td>
<?php
$productClass = hikashop_get('class.product');
$product = $productClass->get($item->product_id);
echo $product->mereinfo; ?>

and that will display your custom product field.

If that doesn't work, are you sure that your custom field is of the table "product" ?
Could you do a screenshot of your custom field options ?

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

  • Posts: 8
  • Thank you received: 0
12 years 11 months ago #31312

I have made two different fields. One as Product, and one as Item.

I have published both, but only the "Item" appears on product page.

Any ideas?

Attachments:

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
12 years 11 months ago #31344

So yo'ure talking about a custom item field where the user can enter some text on the product page ?
In that case, that is already displayed automatically in the email if the user enters something in the field. There is nothing to do.

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
12 years 11 months ago #31345

So yo'ure talking about a custom item field where the user can enter some text on the product page ?
In that case, that is already displayed automatically in the email if the user enters something in the field. There is nothing to do.

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

Time to create page: 0.057 seconds
Powered by Kunena Forum