Author Topic: Add product attribute in header invoice  (Read 240 times)

Huubs

  • Jr. Member
  • **
  • Posts: 215
Add product attribute in header invoice
« on: January 31, 2020, 13:34:51 pm »
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:

Code: [Select]
<?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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4331
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Add product attribute in header invoice
« Reply #1 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

Huubs

  • Jr. Member
  • **
  • Posts: 215
Re: Add product attribute in header invoice
« Reply #2 on: February 01, 2020, 14:08:18 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.