Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

problem with SHOPPING CART and $cart


jvendima

Recommended Posts

hi, i'm new here so ....

Hello all

 

I had a problem with my shopping cart it allways displayed 00 items and wen a customer buy something it past to 10 items .

How can i do to retire the 2º 0, and what and were a fix it.

thanks for help

 

Here the code i had in the header.php

 

</td>

<td style="background: url(images/template/bar_loop.gif) repeat-x;width:100%;height:58px;font-size:12px;font-family:Verdana, Arial, Helvetica, sans-serif;" align="right">

<p style="text-align:center;">

<a href="<?php echo tep_href_link('shopping_cart.php')?>"><?php echo $cart->count_contents()?> <?php echo BOX_SHOPPING_CART_EMPTY ?></a></p>

</td>

<td align="left" valign="middle">

 

<a href="<?php echo tep_href_link('shopping_cart.php')?>"><?php echo tep_image(DIR_WS_IMAGES . 'cart.gif', BOX_HEADING_SHOPPING_CART); ?></a>

 

 

</td>

Link to comment
Share on other sites

BOX_SHOPPING_CART_EMPTY is defined in /includes/languages/english.php and the definition of it is:

 

0 items

 

So in your code:

 

<a href="<?php echo tep_href_link('shopping_cart.php')?>"><?php echo $cart->count_contents()?> <?php echo BOX_SHOPPING_CART_EMPTY ?></a>

 

Your printing first the number of items in the cart with <?php echo $cart->count_contents()?> ... then your also printing BOX_SHOPPING_CART_EMPTY

 

<?php echo BOX_SHOPPING_CART_EMPTY ?>

 

which as we saw would always print 0 items as this is what it is defined as.

 

So all we need to do is remove that <?php echo BOX_SHOPPING_CART_EMPTY ?> bit of code

 

 

So you have

 

</td>
<td style="background: url(images/template/bar_loop.gif) repeat-x;width:100%;height:58px;font-size:12px;font-family:Verdana, Arial, Helvetica, sans-serif;" align="right">
<p style="text-align:center;">
<a href="<?php echo tep_href_link('shopping_cart.php')?>"><?php echo $cart->count_contents()?> item(s) in cart</a></p>
</td>
<td align="left" valign="middle">

<a href="<?php echo tep_href_link('shopping_cart.php')?>"><?php echo tep_image(DIR_WS_IMAGES . 'cart.gif', BOX_HEADING_SHOPPING_CART); ?></a>


</td>

 

Or use Burt's method @ Club osC

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...