Kelvinejimogu Posted May 9, 2012 Share Posted May 9, 2012 Fatal error: Call to a member function count_contents() on a non-object in /homepages/21/d401541748/htdocs/oscommerce/includes/boxes/shopping_cart.php on line 23 this is the page : <?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 = ''; //this is line 23 if ($cart->count_contents() > 0) { $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0" align="center">'; $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $cart_contents_string .= '<tr><td align="right" valign="top">'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="oldItemInCart">'; } $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="top" width="100%"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="oldItemInCart">'; } $cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { tep_session_unregister('new_products_id_in_cart'); } } $cart_contents_string .= '</table>'; } else { $cart_contents_string = ' 0 '.BOX_SHOPPING_CART_EMPTY; } $temp1 = '<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center"><tr><td>'.$cart_contents_string .'</td></tr></table>'; $temp2 = ''; if ($cart->count_contents() > 0) { $temp2 = '<table cellpadding="0" cellspacing="0" border="0" align="center"><tr><td align="right" height="30" class="vam"><b class="productSpecialPrice">'.$currencies->format($cart->show_total()).'</b></td></tr></table>'; } $info_box_contents = array(); $info_box_contents[] = array('text' => $temp1.$temp2); new infoBox($info_box_contents); ?> </td> </tr> <!-- shopping_cart_eof //--> Im a newbie so any help will be highly appreciated thank you. Link to comment Share on other sites More sharing options...
germ Posted May 9, 2012 Share Posted May 9, 2012 The "cart" object is supposed to be created by code in /includes/application_top.php If it isn't created there that would cause your error. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
MrPhil Posted May 9, 2012 Share Posted May 9, 2012 This appears to be pre-2.2 MS2 code. As of MS2, anyway, includes/application_top.php is required before any use of $cart. As @@germ pointed out, you don't have that in your code, so $cart is undefined at line 23. Any idea what happened? What changes have been made recently (since around the time this error started popping up)? Has someone been making unauthorized changes to your code? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.