item custom field in show order

  • Posts: 27
  • Thank you received: 0
10 years 7 months ago #150825

Hello,

I have an item custom field, a date.
The date appears in the email order, in the cart and that's fine.

But I would like also that appear in the /order/show and print invoice.

Do you have an idea?

THanks
Matteo

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
10 years 7 months ago #150902

Hi,

You have to edit the view "order / show" via the menu Display > Views and add the desired code in the desired place.
The value should be in the variable:

echo $product->order_product_CUSTOMFIELDNAME;

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

  • Posts: 27
  • Thank you received: 0
10 years 7 months ago #150917

THanks, I will try.

...let's say that I have several products, and every product has a different item custom fieldd ( example: Prod. A has a datapicker custom fiend that has a rande from april to june, Prod B only every monday, and so on).

you can imagine I cannot put every single custom code..... How can I write it?

Thanks
Matteo

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

  • Posts: 13201
  • Thank you received: 2322
10 years 7 months ago #150921

Hi,

You can probably set the non custom field columns of in an array, for example:

$notCustom = array('order_product_name','order_product_code',...);
Then check like:
foreach($product as $key => $content){
    if(!in_array($key,$notCustom)){
        if(!empty($content)){
            echo $product->$key;
        }
    }
}

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

  • Posts: 27
  • Thank you received: 0
10 years 7 months ago #151057

Works pretty well, only proble is that they are date values, so i get : 20140515000000 instead of: 2014-05-15

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

  • Posts: 27
  • Thank you received: 0
10 years 7 months ago #151063

Hello,
sorry for my bad php and english!

The solution with one item field works well, but my proble is follow:

- If the product is "tour to london" there is a datefield "date_london" to show in order;
- If the product is "tour to paris" there is a datefield "date_paris" to show in order;
- If the product is "tour to rome" there is a datefield "date_rome" to show in order and another field "time_rome";

Thanks

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

  • Posts: 27
  • Thank you received: 0
10 years 7 months ago #151065

For example, I've added this code to show the custom items in the product cart:

foreach($this->itemFields as $field){
											$namekey = $field->field_namekey;
											if(!empty($row->$namekey)){
												echo '<p style="margin-bottom:0px!important" class="hikashop_cart_item_'.$namekey.'">'.$this->fieldsClass->getFieldName($field).': '.$this->fieldsClass->show($field,$row->$namekey).'</p>';
											}
										}
									}

But of course is not working in Show Order...

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

  • Posts: 27
  • Thank you received: 0
10 years 7 months ago #151095

I need your help!!!

I'm trying to do by myself but I cannot undestand:

I use your plugin advanced datepicker ( the one you've also adjusted me). le'ts' say I put date 16/04/2014
But when in the order > show i write : echo hikashop_getDate($product->data_tratte,'%d %B %Y ');
( the string could be also Y-m-d, makes no difference)
I get "17 Maggio 1994", a total nonsense.
If I dont use hikashop_getDate the timestamp is correct: 20140416000000

But my need is to put in every order the different item custom fields , that they are different for every product.

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

  • Posts: 13201
  • Thank you received: 2322
10 years 7 months ago #151221

Hi,

You can use:
echo date("Y-m-d",$product->$key);

In the order view you can find this kind of code:

										if(hikashop_level(2) && !empty($this->fields['item'])){
											foreach($this->fields['item'] as $field){
												$namekey = $field->field_namekey;
												if(!empty($product->$namekey) && strlen($product->$namekey)){
													echo '<p class="hikashop_order_item_'.$namekey.'">'.$this->fieldsClass->getFieldName($field).': '.$this->fieldsClass->show($field,$product->$namekey).'</p>';
												}
											}
										}

I think that you can adapt in for your needs. As you can see it's $product->$namekey which is used instead of $row->namekey.

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

  • Posts: 27
  • Thank you received: 0
10 years 7 months ago #151248

Hello,

works great!!!

Just for someone who has the same situation, Iv'e adjusted the code:

foreach($this->fields['item'] as $field){
												$namekey = $field->field_namekey;
												if(!empty($product->$namekey)){
													echo '<p class="hikashop_order_item_'.$namekey.'" style="font-size:18px">'.$this->fieldsClass->getFieldName($field).': '.$this->fieldsClass->show($field,$product->$namekey).'</p>';
												}
											}
		
	

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

Time to create page: 0.102 seconds
Powered by Kunena Forum