Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Cart Information in Header


assembler

Recommended Posts

Adds a small line to your header that displays the number of items in the shopping cart, and the current subtotal. Clicking on the number of items or the subtotal brings you directly to the shopping cart. This allows you to remove the shopping cart box from column_right.php, while still allowing your customers to have access to the basic information on every page.

 

Very easy to install. Backup first.

 

Cart Information in Header

Edited by assembler
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

I installed this contribution, and tested it, but everytime i EMPTY the shopping cart, it still says i have 2 items, even though im staring at the cart and there is NOTHING there!

Does anyone know the problem w/ this contrib? thanks!!

Link to comment
Share on other sites

  • 3 months later...
hi,

 

this is *just* what i'm looking for, but i'm trying to get it working with STS/template.html system. any ideas as it doesn't seem to be using the header.php code?

 

cheers, will.

 

It's was exactly what I was looking for too. I used the very first contribution because it was the most simple and I didn't need all the bells and whistles. To implement into STS is simple all you have to do is open up catalog/includes/sts_display_output.php to start...

 

2) Find the following block of code:

 

// Note: These values lifted from the stock /catalog/includes/header.php script's HTML

// catalogurl: url to catalog's home page

// catalog: link to catalog's home page

 

You need to define a new template variable...here's what I used:

 

//Add cart contents to template

$template['cartitemcount'] = sprintf(TEXT_SHOPPING_CART_CONTENTS, $cart_item_count). ' ' . $item_description . $currencies->format($cart->show_total());

 

Simply, copy and paste there.

 

 

3) For this to work properly, you need to create corresponding definitions in your catalog/includes/english.ph p file. The original contribution had the english text hardcoded in so I removed it and added the following:

 

define('TEXT_SHOPPING_CART_CONTENTS', 'You have %s');

define('TEXT_SHOPPING_CART_ITEM', 'item in your cart: ');

define('TEXT_SHOPPING_CART_ITEMS', 'items in your cart: ');

 

4) You'll need to add update the if statement in the catalog/includes/header.php to reflect your english definitions also. The english updates are not really necessary if you don't want to comply with normal osc coding standards.

 

<?php

$cart_item_count = $cart->count_contents();

 

if ($cart_item_count == 1) {

$item_description = TEXT_SHOPPING_CART_ITEM;

 

} else {

 

$item_description = TEXT_SHOPPING_CART_ITEMS;

}

?>

 

5) Okay the final and last step is just adding the variable ($cartitemcount) to your catalog/includes/mysite/sts_template.html file. (I'm assuming you are using the latest version of sts).

 

That's it.

Link to comment
Share on other sites

  • 4 months later...
  • 3 weeks later...

Thanks for the contrib. This was very easy to install. However, I'm having a problem. My shopping cart still shows up even if I comment out the shopping_cart file in column_right. I think this is because of a cache contrib I installed (I don't know for sure) that has the following code in colulmn_right.php:

 

if ($cart->count_contents() > 0) {

if (!tep_session_is_registered('customer_id') && ENABLE_PAGE_CACHE == 'true' && class_exists('page_cache') ) {

echo "<%CART_CACHE%>";

} else {

// require(DIR_WS_BOXES . 'shopping_cart.php');

}

}

 

So, I commented out the above code and everything seemed to be working, but it still isn't quite right.

 

If I add an item to my cart, it shows up correctly in the header, but if I click on catalog in my header, which takes me back to my first page with the list of categories, 1 item is subtracted from my total items in the header. For example, if I am adding the 4th item to my cart, but I go back to my first catalog page (1 item will subtracted out of the total. But, if I click on 3 items in the header (which is what now shows to be my total number of items), I go to the shopping cart page and the 4 items show, which is actually the correct total that I added.

 

I don't know if it has something to do with the cache contribution or not. In fact, I don't know if I have messed anything up by removing the above code from column_right.

 

Anybody have any ideas about this.

 

Thanks.

Link to comment
Share on other sites

Actually, this is problem is worse than I thought. Sometimes the total in header shows 2 items, sometimes 3 items, and sometimes 0 items, depending on what page I'm on.

 

Does anybody know what I need to do. I guess I'll start by removing the contribution code.

 

Thanks.

Link to comment
Share on other sites

  • 2 weeks later...

I just installed this and well It shows in the header but when you click on the button it emties the cart is it supposed to do this.

 

How would I go about changing it to show the cart contents.

 

Thanks for any help.

Link to comment
Share on other sites

  • 4 weeks later...

Greetings,

 

Excellent contrib. It works perfectly on my basic store; however, I'm using STS v4.1 and I cant figure out how to get it to work in the templates. I read the previous post about adding this contrib to STS, but it would seem that was for an earlier version of STS. Can anyone help me with adding this to STS v4.1 (the coding is completely different from earlier versions).

 

Thanks a bunch

Cheers

Shane

Link to comment
Share on other sites

  • 3 months later...
Actually, this is problem is worse than I thought. Sometimes the total in header shows 2 items, sometimes 3 items, and sometimes 0 items, depending on what page I'm on.

 

Does anybody know what I need to do. I guess I'll start by removing the contribution code.

 

Thanks.

 

Did you ever figure out what caused the problem? I got the same with my store now - after enabling cache..

Link to comment
Share on other sites

I took and did it a different way then what this contrib had not saying that it is a bad contrib. I just wanted something a little different. I basically took the whole shopping cart box and put it in the header. To see what I did CLICK HERE This site is still in construction so be gentle. If anyone like what they see I will be glad to post the code for it.

 

Eric

Link to comment
Share on other sites

I figured it out.. :-)

 

I took the code that's supposed to be pasted in application_top (from chemo's cache contrib), and pasted it in the bottom of the header (below cart in header contrib).. Works great now! :-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...