![]() |
How to get Shipping Weight Total from the codeigniter cart class (its in the cart items array) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to get Shipping Weight Total from the codeigniter cart class (its in the cart items array) (/showthread.php?tid=42536) |
How to get Shipping Weight Total from the codeigniter cart class (its in the cart items array) - El Forum - 06-09-2011 [eluser]dwhite7508[/eluser] Hey guys, I have a question about the cart class in codeigniter. This is probably more of an array question, but here it is... I have my products in the codeigniter cart class and i've made a key and value for "weight". It works fine and when I do a print_r on $this->cart->contents() it shows the weight of each item just fine. What i'm not sure of how to do (and i know this is probably simple) is loop through the cart contents and add up the total weight from each product array in the contents array. Any ideas? How to get Shipping Weight Total from the codeigniter cart class (its in the cart items array) - El Forum - 06-10-2011 [eluser]dwhite7508[/eluser] Nevermind, some more thinking on the subject has brought me to a useable solution. I'm posting the answer for anyone looking for the same solution. If you add a "weight" row to your products table and you're using codeigniter's built in cart class, this is how you can get a "total weight" from the products in the cart... Code: $totalWeight = 0; |