Skip to main content

How to display weight in Product Page opencart

Kindly follow the following steps:

Check this code now:
 Go the following location in server or Cpanel

Language File Change

catalog/language/en-gb/product/product.php
Check this $_['text_year']                = 'year';.
Add the following lines to above lines
$_['text_weight']                = 'Weight';



In model Change :

Goto the catalog/model/catalog/product.php
Check the following lines in
public function getProducts($data = array())
Add the following lines above the lines:
public function getWeightClass($weight_class_id)
{
    $sql="SELECT *  FROM " . DB_PREFIX . "weight_class_description WHERE weight_class_id='".$weight_class_id."'";
    $query = $this->db->query($sql);
     if ($query->num_rows)
    {
        return $query->row['unit'];
     
    }
 
}

Goto the catalog/controller/product/product.php


Check the following lines in
$this->load->model('tool/image');
Add the following lines above the lines($this->load->model('tool/image');):
if ($product_info['weight']) {
$data['weight'] = $product_info['weight'];
}
if ($product_info['weight_class_id']) {
$data['weight_class'] = $this->model_catalog_product->getWeightClass($product_info['weight_class_id']);
}


Goto the catalog/view/theme/default/template/product/product.twig


Check the following lines in
<li>{{ text_stock }} {{ stock }}</li>
Add the following lines above the lines($this->load->model('tool/image');):

            <li>{{ text_weight }} {{ weight }} {{ weight_class }}</li>

Comments

Popular posts from this blog

About The Author

Hi All, Welcome to the Opencart Tutorial I have 4.5 Year industry experience in E-commerce and Business website Development. I have created more then 50 Websites.  I am expert in the opencart, wordpress , magento, PHP, HTML5, CSS. I will write this tutorial on opencart website from Installation to module customization

Filter By Brand in opencart

<?xml version="1.0" encoding="UTF-8"?> <modification> <name>Brand By Filter</name> <id>Brand By Filter</id> <code>OCMP_BBF</code> <version>3.0.2</version> <vqmver required="true">2.4.0</vqmver> <author>ManiNalliapppan</author> <file path="catalog/controller/product/category.php"> <operation>             <search><![CDATA[$results = $this->model_catalog_category->getCategories($category_id);]]></search>             <add position="after"><![CDATA[// get manufacturers for child categories $categoryids_with_childs = array(); $categoryids_with_childs = $this->model_catalog_category->getCategoriesByParentId($category_id); array_push($categoryids_with_childs, $category_id); $manufacturers = $this->model_catalog_manufacturer->getManufacturersByCategories(...

Buy Now Adding in Product Page

<?xml version="1.0" encoding="UTF-8"?> <modification> <name>Buy Now Product</name> <id>Buy Now Product</id> <code>OCMP_BNP</code> <version>3.0.2</version> <vqmver required="true">2.4.0</vqmver> <author>ManiNalliapppan</author>     <file path="catalog/language/en-gb/product/product.php"> <operation>             <search ><![CDATA[ $_['text_year']                = 'year'; ]]></search>             <add position="after"><![CDATA[$_['text_buynow']                = 'Buy Now';]]></add>         </operation>   </file>    <file path="catalog/view/theme/default/template/product/product.twig"> <operation>        ...