How to get category in checkout cart in opencart?
<p>first at all thanks for the help... Im new on opencart, hope somebody can help me...</p>

<p>Im getting crazy trying to find the answer in google for my question...</p>

<p>I wanna add the category name in checkout/cart </p>

<pre><code>&lt;a href="&lt;?php echo $product['href']; ?&gt;"&gt;&lt;?php echo $category['name']; ?&gt;&lt;/a&gt;
</code></pre>

<p>I try to add a new variable in the controller of cart.pl, but is impossible, as the answer that i found in internet doesnt work... </p>

<p>BTW i work on Opencart 2.2.0...</p>

<p>this is what i have in cart.pl on my template:</p>

<pre><code>&lt;?php foreach ($products as $product) { ?&gt;      

                &lt;div class="gry_part"&gt;
                        &lt;div class="width1"&gt;

                        &lt;a href="&lt;?php echo $product['href']; ?&gt;"&gt;&lt;?php echo $category['name']; ?&gt;&lt;/a&gt; - 
                        &lt;a href="&lt;?php echo $product['href']; ?&gt;"&gt;&lt;?php echo $product['name']; ?&gt;&lt;/a&gt;

                        &lt;?php if (!$product['stock']) { ?&gt;
                          &lt;span class="stock"&gt;***&lt;/span&gt;
                        &lt;?php } ?&gt;

                        &lt;div&gt;
                            &lt;?php foreach ($product['option'] as $option) { ?&gt;
                            - &lt;small&gt;&lt;?php echo $option['name']; ?&gt;: &lt;?php echo $option['value']; ?&gt;&lt;/small&gt;&lt;br /&gt;
                            &lt;?php } ?&gt;
                            &lt;?php if($product['recurring']): ?&gt;
                            - &lt;small&gt;&lt;?php echo $text_payment_profile ?&gt;: &lt;?php echo $product['profile_name'] ?&gt;&lt;/small&gt;
                            &lt;?php endif; ?&gt;
                          &lt;/div&gt;
                          &lt;?php if ($product['reward']) { ?&gt;
                          &lt;small&gt;&lt;?php echo $product['reward']; ?&gt;&lt;/small&gt;
                          &lt;?php } ?&gt;
                        &lt;/div&gt;
                        &lt;div class="width2 quantity"&gt;
                            &lt;input type="text" name="quantity[&lt;?php echo $product['cart_id']; ?&gt;]" value="&lt;?php echo $product['quantity']; ?&gt;" size="1" /&gt;
                            &lt;input type="image" src="catalog/view/theme/amishop/image/update.png" alt="&lt;?php echo $button_update; ?&gt;" title="&lt;?php echo $button_update; ?&gt;" /&gt;
                        &lt;/div&gt;
                        &lt;div class="width3"&gt;&lt;?php echo $product['price']; ?&gt;&lt;/div&gt;
                        &lt;div class="width4"&gt;
                        &lt;button type="button" data-toggle="tooltip" title="&lt;?php echo $button_remove; ?&gt;" class="add_to99" onclick="cart.remove('&lt;?php echo $product['cart_id']; ?&gt;');"&gt;Delete&lt;/button&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;

        &lt;?php } ?&gt;
</code></pre>

<p>and this is what i try to add in the controller cart.pl</p>

<pre><code>$categories = $this-&gt;model_catalog_product-&gt;getCategories($product_id);
        if ($categories)
            $categories_info = $this-&gt;model_catalog_category-&gt;getCategory($categories[0]['category_id']);
        $this-&gt;data['category_title'] = $categories_info['name'];
</code></pre>

<p>sorry for this, if is quite stupid question, but im new on this...</p>

<p>thanks for all..</p>