Skip to main content

Custom fields on product page

More
14 years 10 months ago - 14 years 10 months ago #31106 by pamolade
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: 14 years 10 months ago by pamolade.

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

More
14 years 10 months ago #31116 by nicolas
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.

More
14 years 10 months ago #31193 by pamolade
Whats second? Because this didn't work :(

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

More
14 years 10 months ago #31221 by nicolas
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.

More
14 years 10 months ago - 14 years 10 months ago #31287 by pamolade
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: 14 years 10 months ago by pamolade.

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

More
14 years 10 months ago #31297 by nicolas
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.

More
14 years 10 months ago #31312 by pamolade
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?

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

More
14 years 10 months ago #31344 by nicolas
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.

More
14 years 10 months ago #31345 by nicolas
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.203 seconds
Powered by Kunena Forum