How to display weight and SKU on the product page in OpenCart?

Practice




How do I display weight and SKU on the product page in OpenCart?

in the file /catalog/controller/product/product.php

add the lines
$this->data['weight'] = round($product_info['weight']);
$this->data['art'] = $product_info['sku'];


foreach ($tags as $tag) {
$this->data['tags'][] = array(
'tag' => trim($tag),
'href' => $this->url->link('product/search', 'filter_tag=' . trim($tag))
);
}


$this->data['weight'] = round($product_info['weight']);
$this->data['art'] = $product_info['sku'];



and in the file /catalog/view/theme/default/template/product/product.tpl

output this in the right place

Вес гр.

Артикул

and to display not just grams but any unit of measurement
you need in Opencart

to do the following in these same files

$this->data['weight'] =
$this->weight->format($product_info['weight'], $product_info['weight_class_id']);

instead of

$this->data['weight'] = round($product_info['weight']);

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)