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?
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?
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
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
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?
Who is online
Users browsing this forum: No registered users and 2 guests