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

Array Question

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 08-26-2003, 12:11 PM
 
machnhed1 machnhed1 is offline
 

eXpert
  
Join Date: Feb 2003
Location: Illinois
Posts: 274
 

Default Array Question

Hi Everyone,

I have this array:
Code:
Array ( [0] => Array ( [productid] => 16141 [amount] => 1 ) [1] => Array ( [productid] => 129 [amount] => 1 ) [2] => Array ( [productid] => 16141 [amount] => 1 ) )
I was wondering if there was a function that would take the values of the array and add up the amounts or identical productids so that the result would look something like this:
Code:
Array ( [0] => Array ( [productid] => 16141 [amount] => 2 ) [1] => Array ( [productid] => 129 [amount] => 1 ) )

I looked on php.net, but either I am missing it or it doesn't exist. Hopefully someone knows how to do this.

Thanks
__________________
Following the signature guidelines : xcart pro 3.5.8 - [RedHat]
Reply With Quote
  #2  
Old 08-27-2003, 03:13 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

Hi,

If you look within cart.php there is already a function there that does this kind of thing.

I guess you are looking to do an add multiple products to cart or something.

If you are it is easier to add all the products/amounts to the array that you are referring to then loop through the cart.php for each element of the array - this will sort the add multiple products side for you plus look at the product options elements aswell.
__________________
ex x-cart guru
Reply With Quote
  #3  
Old 08-27-2003, 05:09 AM
 
machnhed1 machnhed1 is offline
 

eXpert
  
Join Date: Feb 2003
Location: Illinois
Posts: 274
 

Default

FD,

Actually I am making a module that compares what you have in your cart to what people have bought in the past and then recommends products you should consider. I am thinking that I'll put it on the cart.php page and the individual products page.

Thanks for the tip
__________________
Following the signature guidelines : xcart pro 3.5.8 - [RedHat]
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:55 AM.

   

 
X-Cart forums © 2001-2020