How I can show manufacturer on order copy?


I'm a beginner in Litecart and in general with php language.

Could someone help me ?

I found the module is printable_order_copy_inc.php but and these are the lines (I think) :

<th><?php echo language::translate('title_qty', 'Qty'); ?></th>
          <th><?php echo language::translate('title_sku', 'SKU'); ?></th>
          <th class="main"><?php echo language::translate('title_item', 'Item'); ?></th>
          <th class="text-right"><?php echo language::translate('title_unit_price', 'Unit Price'); ?></th>
          <th class="text-right"><?php echo language::translate('title_tax', 'Tax'); ?> </th>
          <th class="text-right"><?php echo language::translate('title_sum', 'Sum'); ?></th>

I can replace the SKU with Manufacturer


In includes/templates/default.catalog/pages/

<th><?php echo language::translate('title_sku', 'SKU'); ?></th>
**Replace with**
<th><?php echo language::translate('title_manufacturer', 'Manufacturer'); ?></th>

<td><?php echo $item['sku']; ?></td>
**Replace with**
<td><?php echo reference::product($item['product_id'])->manufacturer['name']; ?></td>
Thank you Tim
It doesn't work

Notice: Undefined index: name in ~/includes/templates/default.catalog/pages/ on line 121
My bad, it's reference::product($item['product_id'])->manufacturer->name.
I forgot LiteCart references the manufacturer object directly in later versions.
It doesn't work again. Now the message is

Trying to get property 'name' of non-object in ~/includes/templates/default.catalog/pages/
I'm using the latest stable release 2.1.6
I can show the short description instead of manufacturer name if it is simpler
If reference::product($item['product_id'])->manufacturer->name doesn't work then you don't have a manufacturer assigned to that product.

Taken from you can see how the manufacturer is tied:

        case 'manufacturer':

          $this->_data['manufacturer'] = null;

          if (empty($this->_data['manufacturer_id'])) return;

          $this->_data['manufacturer'] = reference::manufacturer($this->manufacturer_id, $this->_language_codes[0]);

If you wanna see if it's set before outputting it:

$product = reference::product($item['product_id'], $order['language_code']);
if (!empty($product->manufacturer)) {
  echo $product->manufacturer->name;
To view short description:
$product = reference::product($item['product_id'], $order['language_code']);
echo $product->short_description;
Or in one command if you have no use for $product elsewhere:
echo reference::product($item['product_id'], $order['language_code'])->short_description;
I can correctly show the short description (with the right translation) even if I have to delete
, $language_code
from the line to avoid error messages.

But I can't show the manufacturer name although all my items have a manufacturer assigned.

I insert your code

$product = reference::product($item['product_id'], $language_code);
if (!empty($product->manufacturer)) {
  echo $product->manufacturer->name;
and I haven't errors neither the manufacturer name.

Thanks again for your help.
What does the following output?

var dump(reference::product($item['product_id'])->manufacturer_id);

Keep in mind it has to be inside the foreach loop to populate $item.

And my bad, $language_code should be $order['language_code'] if you are passing it inside the printable order copy.
Hello Tim,

I don't know why, but in this way it works

<td><?php $product = reference::product($item['product_id'], $order['language_code']);
if (!empty($product->manufacturer_id)) {
  echo $product->manufacturer->name;
} ;?></td>

Thanks for your efforts
Maybe you didn't put it inside the foreach loop before. Glad it's working. Now you have a better understanding how the reference model works. :)