cookie monster Posted April 14, 2008 Posted April 14, 2008 In the header of my template it says "0 items now in your cart." but it always remains at Zero "0" even if logged in and items are in the cart. Anyclue on how to get it working? I tried to add the snippet of php code from the default Cart template but that crashs my Cart. <?php if ($cart->count_contents() > 0) { ?> <td width="134" align="left" valign="middle" height="51" background="images/shopping_bg.gif"><img src="images/shopping_cart_im.gif" width="37" height="37" alt="" align="left" style=" margin:2px 3px 2px 4px;; " /><br/><b>0 items</b><br/>now in your cart.<br/></td> </tr> Not sure if im on the right track here. Help would be appreciated. Thanks
xecutable Posted April 14, 2008 Posted April 14, 2008 In the header of my template it says "0 items now in your cart." but it always remains at Zero "0" even if logged in and items are in the cart.Anyclue on how to get it working? I tried to add the snippet of php code from the default Cart template but that crashs my Cart. <?php if ($cart->count_contents() > 0) { ?> <td width="134" align="left" valign="middle" height="51" background="images/shopping_bg.gif"><img src="images/shopping_cart_im.gif" width="37" height="37" alt="" align="left" style=" margin:2px 3px 2px 4px;; " /><br/><b>0 items</b><br/>now in your cart.<br/></td> </tr> Not sure if im on the right track here. Help would be appreciated. Thanks You are missing a small part this is my code: <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART); //new infoBoxHeading($info_box_contents, false, false, false); $cart_contents_string = ''; $cart_contents_string .= '<img src="images/shop_cart.jpg" width="37" height="37" align="left" style="margin-right:3px;" /><b>'.BOX_HEADING_SHOPPING_CART.'</b><br/> Now in your cart <br/>'.sizeof($products = $cart->get_products()).' Items'; $info_box_contents = array(); $info_box_contents[] = array('text' => $cart_contents_string);
cookie monster Posted April 15, 2008 Author Posted April 15, 2008 After hours of trial and error (and some help from xecutable) trying to slim this code down and get the correct thing to show within the cart Header ive pretty much given up for the day... Im trying to get the header to show is the cart image and the text: "3" Items in your cart or something simple like that. The default OSC template has the product name and a link and a total $ amount in the shopping-cart.php box. What i really need is someone to cut out all the extra's and only have what i need- my templates cart system box in the header did not work at all, just had this simple text in the top right- it never updated: (my cart: http://directbmx.co.za/catalog) <td width="134" align="left" valign="middle" height="51" background="images/shopping_bg.gif"><img src="images/shopping_cart_im.gif" width="37" height="37" alt="" align="left" style=" margin:2px 3px 2px 4px;; " /><b>Shopping cart</b><br/>now in your cart <br/> 0 items<br/></td> This is from the default OSC shopping cart php file...its the closest thing i can find that will probably work: <?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_cart')) && ($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_cart')) && ($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_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 .= 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); ?> Somewhere around this area im guessing: $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']) . '">'; Shucks, i aint lazy! my brain is swirling numbers, letters and { } right now!!
photofxplus Posted April 15, 2008 Posted April 15, 2008 $cart_contents_string .= $cart->count_contents() . ' Items in your cart'; <b>Shopping cart</b><br/>now in your cart <br/><?php echo $cart->count_contents(); ?> items<br/></td> Lloyd
cookie monster Posted April 15, 2008 Author Posted April 15, 2008 Many thianks, will give it a whirl. ;)
cookie monster Posted April 15, 2008 Author Posted April 15, 2008 Works great, thanks very very much.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.