Post by chinapresentations » Wed Jul 10, 2019 11:42 pm

I am looking to add a link in all product descriptions like "See more from this range" which will automatically take the buyer to the category where the product lives. Does anyone know some code which might achieve this?


Posts

Joined
Wed Jun 26, 2019 10:39 pm

Post by chinapresentations » Thu Jul 11, 2019 6:22 am

Alternatively if not possible in product description would anyone know of some way of adding it into the product page using some kind of tweak to the php files?


Posts

Joined
Wed Jun 26, 2019 10:39 pm

Post by ostechnologies » Thu Jul 11, 2019 2:55 pm

For default theme opencart 3.x
Open catalog/product/product.php
Search for
$data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
Add after :
$categories = $this->model_catalog_product->getCategories((int)$this->request->get['product_id']);
$data['category_links'] = array();
foreach ($categories as $category) {
//print_r($category);die;
$data['category_links'][] = array(
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);

}

Open /catalog/view/theme/default/template/product/product.twig

Search for :
<div class="tab-pane active" id="tab-description">{{ description }}</div>
Add after :
<p>Related Links</p>
<ul>
{% for category_link in category_links %}
<li><a href="{{ category_link.href }}">{{ category_link.href }}</a></li>
{% endfor %}
</ul>

END

Opencart Expert | sales[at]ost.agency
Skype - manish.osuniverse | Gtalk - manishmt

Extensions for Opencart @ https://www.ost.agency/product/product- ... extensions
ost.agency - ecommerce website design, development and digital company


User avatar
Active Member

Posts

Joined
Mon Apr 06, 2015 1:30 pm

Post by chinapresentations » Thu Jul 11, 2019 4:31 pm

Thanks for your reply ostechnologies. I tried that but I am using Journal 3 theme (not default) so it did not work. Any idea how to get that working with Journal?


Posts

Joined
Wed Jun 26, 2019 10:39 pm
Who is online

Users browsing this forum: No registered users and 2 guests