Post by tstirler » Mon Feb 19, 2018 4:58 pm

I'm looking for a way to insert a snippet of text or html/php into several products via text I choose in the product-text.

Example: I have several products that have the same options and I want the product-text to show some info about it, but I don't want to edit all the products if I need to change the text a bit.
How can I enter a tag into the product-text, and have opencart swap out the tag with the text I want?
If I just do a php include in the product-text opencart comments out the php code.

running Opencart 3.0.2.0, and I have vqmod installed. There is no mod in question, rather where to parse the product-text for a specific tag.
Edit: cleared up question.
Last edited by tstirler on Tue Feb 20, 2018 2:57 pm, edited 1 time in total.

______________________________
Out of my mind. Back in five minutes.


User avatar
Newbie

Posts

Joined
Tue Feb 06, 2018 5:22 pm

Post by straightlight » Tue Feb 20, 2018 6:00 am

Code example / attachment un-provided nor knowing if this request is about a specific extension being used.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by tstirler » Tue Feb 20, 2018 2:54 pm

I'll rephrase the question a bit then. :)
What file parses out the Product Info (vanilla OC 3)? I think it should be catalog/model/catalog/product.php.
So that I can scan it for a tag I choose to make and if I find it insert my text/html/php code there.
I see that the query around line 10 fetches and returns the array of data.

Code: Select all

if ($query->num_rows) 
But I've not found a place where I can actually do something with that piece of text.

What I want to insert is a standard set of info, say from my own php-file somewhere, pulled in via a standard php-include. That way I have one place to change the included text and it'll change for all products that use it.
I have no proper code example yet since I've not managed to find where I want said code.
Although it will be a simple: if tag found replace with php-include

______________________________
Out of my mind. Back in five minutes.


User avatar
Newbie

Posts

Joined
Tue Feb 06, 2018 5:22 pm

Post by straightlight » Tue Feb 20, 2018 6:15 pm

Better to use OCMod, VQMod or the override engine to do this without overriding core files. You could also create an extension module and route it to the product page to make things easier by also adding a new model file (might use a bit more SQL resource but still works).

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by tstirler » Tue Feb 20, 2018 6:59 pm

I thought as much. I've no problem doing this with vqmod, if I could just get it to work. :laugh:
Do I need to hook into product.php to catch this?
I tried earlier to do it via the template (now twig) but it didn't change it for me.

______________________________
Out of my mind. Back in five minutes.


User avatar
Newbie

Posts

Joined
Tue Feb 06, 2018 5:22 pm
Who is online

Users browsing this forum: Baidu [Spider] and 92 guests