News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Add product attribute in header invoice

Started by Kuubs, January 31, 2020, 13:34:51 PM

Previous topic - Next topic

Kuubs

Hello,

I'm trying to add a custom field value (text input from the customer in the product) to the header of the invoice. But this is the code for the product attributes:

<?php
if (!empty(
$item->product_attribute)) {
if(!class_exists('VirtueMartModelCustomfields'))require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'customfields.php');
$product_attribute VirtueMartModelCustomfields::CustomsFieldOrderDisplay($item,'FE');
echo $product_attribute;
}
?>


But is it possible to somehow extract one kind of custom field? Now it's all the custom fields with a white space between them.

Studio 42

If you only have somple values, you can check in the $item directly and get the value
For eg.
      if (!empty($item->product_attribute)) {
         $atributes = json_decode ($item->product_attribute, TRUE);
      }
$atributes is then all the customfields set as an array
You can use PHP var_dump or print_r ... to see what you have inside

Kuubs

Quote from: Studio 42 on January 31, 2020, 13:43:42 PM
If you only have somple values, you can check in the $item directly and get the value
For eg.
      if (!empty($item->product_attribute)) {
         $atributes = json_decode ($item->product_attribute, TRUE);
      }
$atributes is then all the customfields set as an array
You can use PHP var_dump or print_r ... to see what you have inside

Ok thank you, I'll check if that works for me.