Undefined Posted September 9, 2004 Share Posted September 9, 2004 Is there a variable that I can call(an array) that contains all the products in the users shopping cart? Hopefully the array will have a way where I can pull the products weight weight from it also. I'm trying to make a for statement that goes through the product weights in the shopping cart to pass them into another variable. I'm not the best with php, but most languages have a similar structure, and I need to make some changes for my own purposes. Quote Link to comment Share on other sites More sharing options...
dittone Posted September 9, 2004 Share Posted September 9, 2004 Is this what you are looking for $products = $cart->get_products(); This will store the cart info in the var $products Quote Link to comment Share on other sites More sharing options...
Undefined Posted September 9, 2004 Author Share Posted September 9, 2004 i'm trying to edit the quote function in the table.php file. I want the shipping costs for each weight category set up in the table added together, instead of calculating by the total weight. For example: if my table was given 2:1.13,4:1.18 and the cart had three items, 2 items at 2ounces and one at 4ounces the shipping cost should be 3.44. Like I said i don't really have much experience with php so bare with me, but it seems pretty straight forward. $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST); $size = sizeof($table_cost); for ($i=0, $n=$size, $z=0; $z<$n; $i+=2, z+=1) { if ($the_array_of_weights_in_cart[$z] <= $table_cost[$i]) { echo $shipping; //this is just to show me what's happening $shipping += $table_cost[$i+1]; //break; take the break out to keep the loop going } in theory if the $the_array_of_weights_in_cart[] was an array of the weights in the cart this would work, but i'm not sure. Thanks for any help in advance. Quote Link to comment Share on other sites More sharing options...
dittone Posted September 9, 2004 Share Posted September 9, 2004 The way I would do it is to create a summary table based on what you want to control or sum by and pass through the file again and accum on each bucket item to get a sum weight and then go and match the table with the total weight from the sum table. It wil require you to know some coding technique. Hope this helps you. Quote Link to comment Share on other sites More sharing options...
Undefined Posted September 9, 2004 Author Share Posted September 9, 2004 I appreciate all your help. I understand what you're saying. I guess I need to get to reading on php. How close is it to c++? I was looking over the code and I can pretty much pick up on most of the logic throughout the files. Ands thanks again. Quote Link to comment Share on other sites More sharing options...
dittone Posted September 10, 2004 Share Posted September 10, 2004 Here is some more to think about...this method gets the info from the shopping cart... $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $products = $cart->get_products(); $products_manufacturers_query = tep_db_query("select products_id, manufacturers_id, products_price, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products[$i]['id'] . "'"); store info into array $this->t_origion[$i] = array('manufacturers_zipcode' => $this->origion[$i]['manufacturers_zipcode'], 'manufacturers_id' => $this->origion[$i]['manufacturers_id'], 'manufacturers_name' => $this->origion[$i]['manufacturers_name'], 'products_id' => $this->origion[$i]['products_id'], 'products_weight' => '0', 'products_weight_fedx' => '0', 'products_weight_truck' => '0', 'products_price' => '0', 'products_quantity' => '0'); The whole thing takes a little planning....but if you have a good background in C++ then you should understand what I am doing above ie C The answer PHP is written in C,C++ and the style is very much the same...Oh by the way PHP is wonderfull...it allows you to interface or get to Database product directly SQl imbedded into PHP... Good luck Quote Link to comment Share on other sites More sharing options...
Undefined Posted September 12, 2004 Author Share Posted September 12, 2004 Thanks for your help. I will definately take this into account while trying to tackle this. By the way, in your opinion is php better than asp? Just curious since I want to get into web programming. I'll probably pick up a book or two on SQL while i'm at it. Quote Link to comment Share on other sites More sharing options...
dittone Posted September 12, 2004 Share Posted September 12, 2004 Every language has its plus and minus...I have been programming many years and know many languages...So to answer this with a yes or no would be unfare to the other languages. I have found php to be a good workable language it has many pluses and only a few negs...But when I browse the internet I find that php is used alot...Just like Apache/Linux. Their are many user groups that use php and make improvements to the language...MSFT languages don't give you their source code and the testers and the inhancements are done by MSFT employees. So my thinking combined with my years in this business allows me to express this opion other people may see thinks differently and thats ok too. I have worked with php/mysql and find alot of quality in the products... As before good luck...If you have anymore questions just post them I monitor the different forums to help where I can. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.