Product category on cart page in opencart 2.2.0.0

To show product category in cart page, you have to do some custom work i.e. you have to overwrite cart page module. Here is the way, you have to do following things

  1. Add OCMOD file to overwrite
    <?xml version="1.0" encoding="utf-8"?>
    <modification>
        <name>Category_Cart</name>
        <version>1.0</version>
        <code>Category_Cart</code>
        <author>A2bizz</author>
        <link>http://blog.a2bizz.com</link>
        <file path="catalog/view/theme/*/template/checkout/cart.tpl">
            <operation>
                <search><![CDATA[
               <td class="text-left"><?php echo $column_name; ?></td>
                ]]></search>
                <add position="after" offset="0"><![CDATA[
                <td class="text-left"><?php echo $column_category; ?></td>
                ]]></add>
            </operation>
             <operation>
                <search><![CDATA[
               <td class="text-left"><?php echo $product['model']; ?></td>
                ]]></search>
                <add position="before" offset="0"><![CDATA[
                <td class="text-left"><?php echo $product['category_name']; ?></td>
                ]]></add>
            </operation>
        </file>
        <file path="catalog/controller/checkout/cart.php">
            <operation>
                <search><![CDATA[
               $data['column_name'] = $this->language->get('column_name');
                ]]></search>
                <add position="after" offset="0"><![CDATA[
                $data['column_category'] = $this->language->get('column_category');
                ]]></add>
            </operation>
             <operation>
                <search><![CDATA[
               $this->load->model('tool/upload');
                ]]></search>
                <add position="after" offset="0"><![CDATA[
                $this->load->model('catalog/custom');
                ]]></add>
            </operation>
            <operation>
                <search><![CDATA[
               $product_total = 0;
                ]]></search>
                <add position="before" offset="0"><![CDATA[
                $category_name = $this->model_catalog_custom->getproductcategory($product['product_id']);
                ]]></add>
            </operation>
            <operation>
                <search><![CDATA[
               'name'      => $product['name'],
                ]]></search>
                <add position="after" offset="0"><![CDATA[
                'category_name'=>$category_name,
                ]]></add>
            </operation>
        </file>
         <file path="catalog/language/*/checkout/cart.php">
            <operation>
                <search><![CDATA[
               $_['column_name']              = 'Product Name';
                ]]></search>
                <add position="after" offset="0"><![CDATA[
                $_['column_category']              = 'Product Category';
                ]]></add>
            </operation>
        </file>
    </modification>
  2. Add a custom model file under catalog/model/catalog/custom.php

    <?php
    class ModelCatalogCustom extends Model {
        public function getproductcategory($product_id){
            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
            $category = $this->getCategory($query->row['category_id']);
            return $category['name'];
        }
    
        public function getCategory($category_id) {
            $query = $this->db->query("SELECT DISTINCT *, (SELECT GROUP_CONCAT(cd1.name ORDER BY level SEPARATOR '&nbsp;&nbsp;&gt;&nbsp;&nbsp;') FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "category_description cd1 ON (cp.path_id = cd1.category_id AND cp.category_id != cp.path_id) WHERE cp.category_id = c.category_id AND cd1.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY cp.category_id) AS path, (SELECT DISTINCT keyword FROM " . DB_PREFIX . "url_alias WHERE query = 'category_id=" . (int)$category_id . "') AS keyword FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd2 ON (c.category_id = cd2.category_id) WHERE c.category_id = '" . (int)$category_id . "' AND cd2.language_id = '" . (int)$this->config->get('config_language_id') . "'");
    
            return $query->row;
        }
    }
  3. Go to in Admin Dashboard -> Extensions -> Extension installer

    Upload you ocmod.xml file from here.

  4. Go to Admin Dashboard -> Extensions-> Modifications

    Click refresh button to create the new ocmod cache file.
    Product category on cart

Enjoy !