Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

"x" items in shopping cart


davinciarte

Recommended Posts

Posted

Instead of having the full shopping cart infobox, I want to just have a line on the header of my website that says "x item(s) in your cart ." Is there a simple way to do this?

Posted

Sure... anything is possible. :)

Add this code to anywhere you want it to be displayed (like your header).

 

<?php echo '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '" class="yourClass">';?>
View Cart: <?php echo $cart->count_contents(); if ($cart->count_contents() == 1) {echo ' Item, ';}else{echo ' Items, ';}
echo $currencies->format($cart->show_total()); ?>

 

It displays the following as a link to your cart:

View Cart: 1 Item, $12.59

or

View Cart: 2 Items, $25.18

HTH,

Robert

Posted

Forgive me my ignorance, but I'm more of an HTML guy than a PHP guy.

 

Is there an easy way to visualize the layout of a php page such as the header.php page? For example, if I wanted to place the code that you just gave me in a specific cell in the header, where in the PHP code would I insert it? Or alternatively if I wanted to add or delete table cells in the header, where in the code would I do this?

 

I hope I'm not asking something that requires too lengthy an explanation. If so, please tell me and I'll try to do some research on my own.

Posted

Essentially the code that I posted above is copy and paste. There is one exception that the "yourClass" should be a valid class within your stylesheet (that's more of an HTML/CSS thing).

 

As you probably know, the php pages within osCommerce is a mix of HTML and PHP. Choose a page such as header.php. Copy the code above and paste it within any HTML code that you want and it should work.

 

If you're still having problems with the implentation, PM me and I'll be glad to help.

Robert

Archived

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

×
×
  • Create New...