dylanjones Posted December 19, 2005 Posted December 19, 2005 I am trying to use PHP variables , and I am having some troubles. I am trying to insert a shopping cart dealy. Using osCommerce and instead of using the boxes on the side I want just to add it to add the number of items in the cart into a table. like this; http://osc.template-help.com/9789/index.php see how it says "you have 0 items" I want that, here is my site; www.imousestudios.com/osc at the top you can see where it should say it. Code: <TD background="images/header_03.gif" WIDTH=105 HEIGHT=23 ><a class=ch2 href="http://www.imousestudios.com/osc/shopping_cart.php"><?php ?></a></TD> That is my table, and I was thinking their might be a variable I could get that shows the number of products in current shopping cart. Here is the shopping_cart.php where all the box shopping cart functions and code is; Code: <?php /* $Id: shopping_cart.php,v 1.18 2003/02/10 22:31:06 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ ?> <!-- shopping_cart //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART); new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART)); $cart_contents_string = ''; if ($cart->count_contents() > 0) { $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">'; $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $cart_contents_string .= '<tr><td align="right" valign="top" class="infoBoxContents">'; if ((tep_session_is_registered('new_products_id_in_ca rt')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="infoBoxContents">'; } $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="top" class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">'; if ((tep_session_is_registered('new_products_id_in_ca rt')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="infoBoxContents">'; } $cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>'; if ((tep_session_is_registered('new_products_id_in_ca rt')) && ($new_products_id_in_cart == $products[$i]['id'])) { tep_session_unregister('new_products_id_in_cart'); } } $cart_contents_string .= '</table>'; } else { $cart_contents_string .= BOX_SHOPPING_CART_EMPTY; } $info_box_contents = array(); $info_box_contents[] = array('text' => $cart_contents_string); if ($cart->count_contents() > 0) { $info_box_contents[] = array('text' => tep_draw_separator()); $info_box_contents[] = array('align' => 'right', 'text' => $currencies->format($cart->show_total())); } new infoBox($info_box_contents); ?> </td> </tr> <!-- shopping_cart_eof //--> Now someone really good at PHP or anyone who knows how to get this work It would save me hours of work! Thank you!
Guest Posted December 20, 2005 Posted December 20, 2005 this is the wrong forum and am moving to general support
Guest Posted December 20, 2005 Posted December 20, 2005 use the $cart variable to retrieve them $cart->count_contents() and for further details on the actual products $cart->get_products(); to get the products array.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.