Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Adding extra variable to $product array

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 04-09-2014, 12:38 PM
 
jlat jlat is offline
 

Member
  
Join Date: Jan 2014
Posts: 17
 

Default 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.
__________________
xcart Gold Plus 4.6.3
Reply With Quote
  #2  
Old 04-09-2014, 01:14 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Adding extra variable to $product array

I think you want to look at include/func/func.product.php
"function func_select_product"
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 04-09-2014, 10:24 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Adding extra variable to $product array

I believe $product['categoryid'] already exists.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #4  
Old 04-10-2014, 12:54 AM
 
jlat jlat is offline
 

Member
  
Join Date: Jan 2014
Posts: 17
 

Default 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"
__________________
xcart Gold Plus 4.6.3
Reply With Quote
  #5  
Old 04-10-2014, 12:56 AM
 
jlat jlat is offline
 

Member
  
Join Date: Jan 2014
Posts: 17
 

Default 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.
__________________
xcart Gold Plus 4.6.3
Reply With Quote
  #6  
Old 04-10-2014, 05:12 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #7  
Old 04-10-2014, 06:06 AM
 
jlat jlat is offline
 

Member
  
Join Date: Jan 2014
Posts: 17
 

Default 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.
__________________
xcart Gold Plus 4.6.3
Reply With Quote
  #8  
Old 04-10-2014, 09:13 AM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default 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.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following user thanks cherie for this useful post:
jlat (04-10-2014)
  #9  
Old 04-10-2014, 10:05 AM
 
jlat jlat is offline
 

Member
  
Join Date: Jan 2014
Posts: 17
 

Default Re: Adding extra variable to $product array

Excellent, thanks very much.
__________________
xcart Gold Plus 4.6.3
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:24 AM.

   

 
X-Cart forums © 2001-2020