Page 1 of 1
Put a text att product page for specific category
Posted: Thu Mar 10, 2022 7:18 pm
by todavy
How do I put a specific text at the botton on all products belong to a specific category (so I dont have to copy-past in on every single product)?
Opencart 3.0.3.7.
Re: Put a text att product page for specific category
Posted: Thu Mar 10, 2022 7:56 pm
by paulfeakins
todavy wrote: ↑Thu Mar 10, 2022 7:18 pm
How do I put a specific text at the botton on all products belong to a specific category (so I dont have to copy-past in on every single product)?
Opencart 3.0.3.7.
If you can't find an extension, you could pay a developer such as
ourselves or post a job in the
Commercial Support Forum.
Re: Put a text att product page for specific category
Posted: Thu Mar 10, 2022 9:09 pm
by Gergely
Hi todavy,
Without extensions, this is the method that comes to mind:
- Create the message
Go to Admin > Extensions > Extensions > Modules > HTML Content. If you haven't used this before you'd need to install it first (click on the green + icon), otherwise just create a new module. Name your module something like "Message for Products in Category X", leave the Heading Title empty, and write the required message in Description.
- Create layout
Go to Admin > Design >Layouts. Create a new layout with the same details as your current product layout, and name it something like "Product - Category X". Delete the route part and add the module created in the previous step to the top of the Content Bottom section.
- Assign layout to product
Go to Admin > Products and find one of the products you want to display this message for. Edit the product, and on the Layout Override section of the Design tab choose the layout created in the previous step.
- (Optional) Assign layout to the rest of the products
Either assign this layout for all necessary products, or use one of the Import/Export tools to do this for the whole category at once.
This is of course not the most convenient solution imaginable, but can be done within the opencart system without modifications.
Hope this helps,
Gergely
Re: Put a text att product page for specific category
Posted: Thu Mar 10, 2022 9:11 pm
by straightlight
Yes, agreed. No custom modifications are required with this request.
Re: Put a text att product page for specific category
Posted: Thu Mar 10, 2022 9:59 pm
by todavy
Thanks! The problem here is that the HTML-modules appear under the "Related products" section. I want it to be above that, as a continuing part of the product text. Is it possible to move the position of my new HTML-module to above the "Related products" module?
I'm curious though to know how the same would be done with a little code in the product.twig-file like: if category_id = 25 then print "Hello world!". Wouldn't that be a faster sollution?
Re: Put a text att product page for specific category
Posted: Thu Mar 10, 2022 10:15 pm
by halfhope
todavy wrote: ↑Thu Mar 10, 2022 9:59 pm
Thanks! I'll try that right away! I'm curious though to know how the same would be done with a little code in the product.twig-file like:
if category_id = 25 then print "Hellp world!". Wouldn't that be a faster sollution?
Hi.
Check out my Extended layout extension. It can display any module (For example, HTML) only for products in a certain category.
todavy wrote: ↑Thu Mar 10, 2022 9:59 pm
Wouldn't that be a faster sollution?
Yes, it's a quick
hardcoded solution.
Re: Put a text att product page for specific category
Posted: Thu Mar 10, 2022 10:15 pm
by mikeinterserv
So what do you have just ONE text for ONE category or will it change over time.
Re: Put a text att product page for specific category
Posted: Thu Mar 10, 2022 10:59 pm
by todavy
The text will be the same for every product of the same kind (dietary supplements must have a specific disclaimer accordning to regulation). Supplements are put in a specific category so I thought that the category could be used for this. But I see now that this is not the optimal way as there are categories that mix those products with others that are not supplements (and those should not have this disclaimer). An optimal solution would be to activate this disclaimer for each product in the Admin/catalog/product but this might not be done without a module. I cant use attributes as they have to be entered for each product.
Choosing another Design/Layout override for supplements might be the closest I could come, if I could just move the "Related products" under this HTML-disclimer.
Re: Put a text att product page for specific category
Posted: Thu Mar 10, 2022 11:07 pm
by straightlight
todavy wrote: ↑Thu Mar 10, 2022 10:59 pm
The text will be the same for every product of the same kind (dietary supplements must have a specific disclaimer accordning to regulation). Supplements are put in a specific category so I thought that the category could be used for this. But I see now that this is not the optimal way as there are categories that mix those products with others that are not supplements (and those should not have this disclaimer). An optimal solution would be to activate this disclaimer for each product in the Admin/catalog/product but
this might not be done without a module. I cant use attributes as they have to be entered for each product.
Choosing another Design/Layout override for supplements might be the closest I could come, if I could just move the "Related products" under this HTML-disclimer.
Correct. An extension module would be needed for this since what you're looking for is to filter specific categories that would match every product of the same kind. Thankfully, in OC v3.x releases, path IDs can be tracked in the product page. If you cannot find a specific extension on the Marketplace that could achieve this already, you could either duplicate an existing module and lookup for the category ID, create a new service request in the Commercial Support section of the forum, or contact me directly via the forum PM to get this done as a custom job.
Re: Put a text att product page for specific category
Posted: Thu Mar 10, 2022 11:18 pm
by halfhope
todavy wrote: ↑Thu Mar 10, 2022 10:59 pm
But I see now that this is not the optimal way as there are categories that mix those products with others that are not supplements (and those should not have this disclaimer). An optimal solution would be to activate this disclaimer for each product in the Admin/catalog/product but this might not be done without a module. I cant use attributes as they have to be entered for each product.
"Extended layout" can also show/hide modules for selected products.
todavy wrote: ↑Thu Mar 10, 2022 10:59 pm
Choosing another Design/Layout override for supplements might be the closest I could come, if I could just move the "Related products" under this HTML-disclimer.
To display modules before related products you can simply move {{ content_bottom }} in product.twig file
Re: Put a text att product page for specific category
Posted: Fri Mar 11, 2022 12:41 am
by todavy
Thanks, but how do I I make a special .twig for the new layout? I might not want the "Related products" to be under every HTML-module...

Re: Put a text att product page for specific category
Posted: Fri Mar 11, 2022 1:49 am
by halfhope
todavy wrote: ↑Fri Mar 11, 2022 12:41 am
Thanks, but how do I I make a special .twig for the new layout? I might not want the "Related products" to be under every HTML-module...
- Move content_bottom before "related products"
- Create new layout (e.g. Product2) with path "product/product" (copy of Product layout)
- Edit product > Layout tab > Select new layout (Product2) for each product
- Create HTML module with your content
- Place HTML module on new layout
All products will have the default "Product" layout, the selected ones will have the "Product2" layout. The product.twig template will be common for all products. Due to the movement of the module output position, all modules displayed on the product page in the content_bottom position will be displayed before the "related products" module, regardless of the layout.
I also have an extension that can change product.twig for selected products (Custom Templates Pro) to yours (e.g. product_2.twig).
Re: Put a text att product page for specific category
Posted: Fri Mar 11, 2022 6:56 am
by todavy
Thank you halfhope! You saved my day.
Re: Put a text att product page for specific category
Posted: Fri Mar 11, 2022 9:34 pm
by straightlight
todavy wrote: ↑Fri Mar 11, 2022 6:56 am
Thank you halfhope! You saved my day.
Now that the issue has been solved, please add: [SOLVED] at the beginning of the subject line on your first post.