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

Opencart Folder Struture And Admin URL Rename

Opencart Folder Struture The Opencart Contain Following folder: 1. Admin 2.Catalog 3.Image 4. System Following Files: 1.index.php 2.config.php 3. .htaccess.txt 4. instructions.txt 5.  license.txt How to rename admin URL in opencart: For Example : http://example.com/admin/  to  http://example.com/ExampleAdmin/ 1. We need to rename admin to ExampleAdmin. 2.  We need to change following  line in  config.php file define('HTTP_SERVER', 'http://example.com/admin/'); define('HTTPS_SERVER', 'https://example.com/admin/'); define('DIR_APPLICATION', 'C:/xampp/htdocs/bunjeeopencart/admin/'); define('DIR_LANGUAGE', 'C:/xampp/htdocs/bunjeeopencart/admin/language/'); define('DIR_TEMPLATE', 'C:/xampp/htdocs/bunjeeopencart/admin/view/template/'); Changed To define('HTTP_SERVER', 'http://example.com/ExampleAdmin/'); define('HTTPS_SERVER', 'https://...

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

How Install SSL in Opencart Site

After installing SSL certificate, we need to  configure the opencart in three things 1. Config.php 2. Admin setting 3. Htaccess 1. Config.php File: The config file is in two location. 1. In domain root  We need to change the following line: define('HTTPS_SERVER', 'http://example.com/'); Changed To define('HTTPS_SERVER', 'https://example.com/'); 2. admin folder We need to change the following line: define('HTTPS_SERVER', 'http://example.com/admin/'); define('HTTPS_CATALOG', 'http://example.com/'); Changed to: define('HTTPS_SERVER', 'https://example.com/admin/'); define('HTTPS_CATALOG', 'https://example.com/'); 2. Admin Side: We need to change the some configuration in admin side:  After login to the Opencart admin panel Goto the System -> Setting-> Server Tab In Security Secetion We need to change Use SSL  to Yes Click to Save ...