Page 1 of 1

Using data from another table

Posted: Wed Apr 28, 2010 7:54 pm
by cumquat
Hi ya,

Ok I have searched the forum and thought I had come close a few times but to no avail. I need to retrieve data from a table and use it on the product display page. Namely I want to query Q's shipping group module table and if shipping_group_id = 3 then don't display the add to cart button.

My question is how and where do I put this query to be able to use that data on the product page.
Does this make sense, hope someone can help it's probably quite simple I'm just not that great at php yet.

Regards

Mick

Re: Using data from another table

Posted: Thu Apr 29, 2010 6:07 am
by SteveSherry
Without having the modules myself I couldn't give you the exact code you need, but you need to edit this file: catalog\view\theme\default\template\product\product.tpl (around line 95)

I also recommend reading this to give you a base for building the code that you'll need.
http://forum.opencart.com/viewtopic.php ... 55&start=0

Re: Using data from another table

Posted: Thu Apr 29, 2010 4:06 pm
by johnnyart
I don't have that module installed but to query another table in the database you can use

Code: Select all

$this->db->query("QUERY HERE");
That way you will be able to place any data of the result on to the product page or wherever you want.

Remember that to access a variable like $var on the template files it has to be declared as $this->data['var'] on the controller!!

Re: Using data from another table

Posted: Thu Apr 29, 2010 5:13 pm
by cumquat
Thanks for your help guys, I know have it sorted thanks to you.

regards

Mick

Re: Using data from another table

Posted: Thu Apr 29, 2010 5:22 pm
by johnnyart
Congratulations :)