OC version.
The category ID is already included in the breadcrumb menu. However, if you want to display the number (which would not have much value to the page itself nor customers), in your catalog/controller/product/product.php file,
find:
Code: Select all
if ($category_info) {
$url = '';
Code: Select all
$data['category_id'] = $category_id;
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Just the number? Surely that's not going to be great for customers?
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
I think want that on admin side...product_list
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
I don't want customers to see the category ID on the product page.paulfeakins wrote: ↑Tue Jun 15, 2021 4:44 pmJust the number? Surely that's not going to be great for customers?
I need to display the category ID on the product page, because I only want to display text for a few categories.
And I thought that if I display the category ID on the product page, I can add a css for the products where I need to display the text
straightlight wrote: ↑Mon Jun 14, 2021 7:24 pmOC version.
The category ID is already included in the breadcrumb menu. However, if you want to display the number (which would not have much value to the page itself nor customers), in your catalog/controller/product/product.php file,
find:
add below:Code: Select all
if ($category_info) { $url = '';
to display your main category ID in your product.twig file. I would suggest to add a TWIG condition in the mean time to ensure the category ID can indeed be displayed based on the URL.Code: Select all
$data['category_id'] = $category_id;
I started as you said yes it did not display in the product page the category id.
I want to display the category id in the product page so that I can add custom css depending on which category the product belongs to
I started doing that:
{% if (categories) %}
{% for category in categories %}
{% if category.category_id %}
<a>{{category.name}}:{{category.category_id}}<a><br>
{% endif %}
{% endfor %}
{% endif %}
if there are products and subcategory, double my box.
displays the correct ID category, but doubles for each subcategory they appear
Simply use an extension for that: https://www.opencart.com/index.php?rout ... n_id=10979 and convert it.Emanuel.C wrote: ↑Tue Jun 15, 2021 5:59 pmstraightlight wrote: ↑Mon Jun 14, 2021 7:24 pmOC version.
The category ID is already included in the breadcrumb menu. However, if you want to display the number (which would not have much value to the page itself nor customers), in your catalog/controller/product/product.php file,
find:
add below:Code: Select all
if ($category_info) { $url = '';
to display your main category ID in your product.twig file. I would suggest to add a TWIG condition in the mean time to ensure the category ID can indeed be displayed based on the URL.Code: Select all
$data['category_id'] = $category_id;
I started as you said yes it did not display in the product page the category id.
I want to display the category id in the product page so that I can add custom css depending on which category the product belongs to
I started doing that:
{% if (categories) %}
{% for category in categories %}
{% if category.category_id %}
<a>{{category.name}}:{{category.category_id}}<a><br>
{% endif %}
{% endfor %}
{% endif %}
if there are products and subcategory, double my box.
displays the correct ID category, but doubles for each subcategory they appear
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
The module you say is compatible with the opencart version less than 2straightlight wrote: ↑Tue Jun 15, 2021 7:10 pmSimply use an extension for that: https://www.opencart.com/index.php?rout ... n_id=10979 and convert it.Emanuel.C wrote: ↑Tue Jun 15, 2021 5:59 pmstraightlight wrote: ↑Mon Jun 14, 2021 7:24 pm
OC version.
The category ID is already included in the breadcrumb menu. However, if you want to display the number (which would not have much value to the page itself nor customers), in your catalog/controller/product/product.php file,
find:
add below:Code: Select all
if ($category_info) { $url = '';
to display your main category ID in your product.twig file. I would suggest to add a TWIG condition in the mean time to ensure the category ID can indeed be displayed based on the URL.Code: Select all
$data['category_id'] = $category_id;
I started as you said yes it did not display in the product page the category id.
I want to display the category id in the product page so that I can add custom css depending on which category the product belongs to
I started doing that:
{% if (categories) %}
{% for category in categories %}
{% if category.category_id %}
<a>{{category.name}}:{{category.category_id}}<a><br>
{% endif %}
{% endfor %}
{% endif %}
if there are products and subcategory, double my box.
displays the correct ID category, but doubles for each subcategory they appear
This module is not compatible with my version of opencart.
My opencart version is 3.0.2.0
There are three words right before the end of the sentence on the instructions. Please read them.Emanuel.C wrote: ↑Wed Jun 16, 2021 10:57 pmThe module you say is compatible with the opencart version less than 2straightlight wrote: ↑Tue Jun 15, 2021 7:10 pmSimply use an extension for that: https://www.opencart.com/index.php?rout ... n_id=10979 and convert it.Emanuel.C wrote: ↑Tue Jun 15, 2021 5:59 pm
I started as you said yes it did not display in the product page the category id.
I want to display the category id in the product page so that I can add custom css depending on which category the product belongs to
I started doing that:
{% if (categories) %}
{% for category in categories %}
{% if category.category_id %}
<a>{{category.name}}:{{category.category_id}}<a><br>
{% endif %}
{% endfor %}
{% endif %}
if there are products and subcategory, double my box.
displays the correct ID category, but doubles for each subcategory they appear
This module is not compatible with my version of opencart.
My opencart version is 3.0.2.0
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: No registered users and 571 guests