0
Assistant Support

How to display Comparison in Opencart header?

How to display Comparison in Opencart header?

0 reviews
09.12.2020

Описание

By default, only selected products, cart, account, menu, and so on are displayed in the template header. But in some cases, product comparisons are sorely lacking. On sites with a large catalog, this is important. All actions were tested on OpenCart 2.x and OcStore 2.x! First, let's output the future text anywhere in our template, I'll output it in the header: Go to catalog/view/theme/default/template/common/header.tpl Find this line:
<code>&lt;li&gt;&lt;a href=&quot;&lt;?php echo $wishlist; ?&gt;&quot; id=&quot;wishlist-total&quot; title=&quot;&lt;?php echo $text_wishlist; ?&gt;&quot;&gt;&lt;i class=&quot;fa fa-heart&quot;&gt;&lt;/i&gt; &lt;span class=&quot;hidden-xs hidden-sm hidden-md&quot;&gt;&lt;?php echo $text_wishlist; ?&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;</code> And after it we insert this: <code>&lt;li&gt;&lt;a href=&quot;&lt;?php echo $compare; ?&gt;&quot; title=&quot;&lt;?php echo $text_compare; ?&gt;&quot;&gt;&lt;i class=&quot;fa fa-exchange&quot;&gt;&lt;/i&gt; &lt;span id=&quot;compare-total&quot; class=&quot;hidden-xs hidden-sm hidden-md&quot;&gt;&lt;?php echo $text_compare; ?&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;</code> Next we need to go to catalog/controller/common/header.php And after the line: <code>$data[&#39;text_checkout&#39;] = $this-&gt;language-&gt;get(&#39;text_checkout&#39;);</code> Paste this: <code>$data[&#39;text_compare&#39;] = sprintf($this-&gt;language-&gt;get(&#39;text_compare&#39;), (isset($this-&gt;session-&gt;data[&#39;compare&#39;]) ? count($this-&gt;session-&gt;data[&#39;compare&#39;]) : 0)); $data[&#39;compare&#39;] = $this-&gt;url-&gt;link(&#39;product/compare&#39;, &#39;&#39;, &#39;SSL&#39;);</code> <code>$data[&#39;text_compare&#39;] = sprintf($this-&gt;language-&gt;get(&#39;text_compare&#39;), (isset($this-&gt;session-&gt;data[&#39;compare&#39;]) ? count($this-&gt;session-&gt;data[&#39;compare&#39;]) : 0)); $data[&#39;compare&#39;] = $this-&gt;url-&gt;link(&#39;product/compare&#39;, &#39;&#39;, &#39;SSL&#39;);</code> And finally, add the text_compare variable for each language (I have Russian and English): 1) Go to catalog/language/ru-ru/common/header.php Insert: <code>$_[&#39;text_compare&#39;] = &#39;Сравнение товаров (%s)&#39;;</code> 2) Go to catalog/language/en-gb/common/header.php Paste: <code>$_[&#39;text_compare&#39;] = &#39;Product сomparison (%s)&#39;;</code> That's all! We go to the store page and see the result.



Автор: DEV-OPENCART.COM

%s reviews

Write a review

Пожалуйста, поставьте оценку:

Bookmarks

Cart (0)

Contacts

Technical support from 10:00 to 19:00, seven days a week

Web laboratory «DEV-OPENCART».
All rights reserved (c) 2018-2026