X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Adding extra variable to $product array (https://forum.x-cart.com/showthread.php?t=69008)

jlat 04-09-2014 12:38 PM

Adding extra variable to $product array
 
Hi,

Does anybody know how to add an extra variable to the $product array? I need to add each product's sub-category id.

Thanks for any advice.

totaltec 04-09-2014 01:14 PM

Re: Adding extra variable to $product array
 
I think you want to look at include/func/func.product.php
"function func_select_product"

cherie 04-09-2014 10:24 PM

Re: Adding extra variable to $product array
 
I believe $product['categoryid'] already exists.

jlat 04-10-2014 12:54 AM

Re: Adding extra variable to $product array
 
Thanks, you're right that's the script. I've managed to figure it out.

Quote:

Originally Posted by totaltec
I think you want to look at include/func/func.product.php
"function func_select_product"


jlat 04-10-2014 12:56 AM

Re: Adding extra variable to $product array
 
Yes, I think you're right, from looking at the func.product.php script that variable is there so I might be able to use that, or if not I'll just look the id/ids up from the database.

Quote:

Originally Posted by cherie
I believe $product['categoryid'] already exists.


totaltec 04-10-2014 05:12 AM

Re: Adding extra variable to $product array
 
Whenever you are wondering if a variable exists, or what is contained in an array, use webmaster mode.

jlat 04-10-2014 06:06 AM

Re: Adding extra variable to $product array
 
yes, I used {$products|@debug_print_var} to inspect the array, seems like there's everything apart from each product's categoryid.

Quote:

Originally Posted by totaltec
Whenever you are wondering if a variable exists, or what is contained in an array, use webmaster mode.


cherie 04-10-2014 09:13 AM

Re: Adding extra variable to $product array
 
Ah, $products is different than $product. Since a product can be in more than one category you may be looking for the product's main category. This info can be pulled from the products_categories table and you may want to do this in include/search.php.

jlat 04-10-2014 10:05 AM

Re: Adding extra variable to $product array
 
Excellent, thanks very much.


All times are GMT -8. The time now is 06:01 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.