Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

make the shopping cart invisible if empty


Guest

Recommended Posts

Posted

on column_right.php i use chemo's page cache seo contribution and i can't figure out how to get this to work.

i do not want the shopping cart infobox to show if the customer has no items in their cart.

 

the code for shopping cart page cache:

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');
  }

Posted

Try:

 

if (!tep_session_is_registered('customer_id') && ENABLE_PAGE_CACHE == 'true' && class_exists('page_cache') ) {
if($cart->count_contents() > 0)
{
 echo "<%CART_CACHE%>";
}
} else {
require(DIR_WS_BOXES . 'shopping_cart.php');
}

Your online success is Paramount.

Posted
Try:

 

if (!tep_session_is_registered('customer_id') && ENABLE_PAGE_CACHE == 'true' && class_exists('page_cache') ) {
if($cart->count_contents() > 0)
{
 echo "<%CART_CACHE%>";
}
} else {
require(DIR_WS_BOXES . 'shopping_cart.php');
}

 

 

you cannot do that with page cache.

 

the <%CART_CACHE%> marker has to be written ALWAYS when the page is being cached or others that DO have something in their cart and hit that cached page will not see their cart.

 

If you want page cache not to show the cart if empty, you need to change that in application_top.php

 

# Start the output buffer for the shopping cart

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

ob_start();

require(DIR_WS_BOXES . 'shopping_cart.php');

$cart_cache = ob_get_clean();

} else {

$cart_cache = '';

}

# End the output buffer for cart and save as $cart_cache string

 

that will make sure that <%CART_CACHE%> in the cached file is replaced by the shopping cart if filled and with nothing if empty, the cached file will keep the <%CART_CACHE%> marker as written by your column_left.php code.

Treasurer MFC

Posted

thank you for that, i was just about to post :D

do i need to add that function, or replace something in application_top?

Posted

the cart seems to still show with yesudo's edit on certain pages... how can i fix this? i would like it to be invisible at all times until there's a product added

Posted
thank you for that, i was just about to post :D

do i need to add that function, or replace something in application_top?

 

in application_top you have something like this :

 

ob_start();

require(DIR_WS_BOXES . 'shopping_cart.php');

$cart_cache = ob_get_clean();

 

 

you make it:

 

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

ob_start();

require(DIR_WS_BOXES . 'shopping_cart.php');

$cart_cache = ob_get_clean();

} else {

$cart_cache = '';

}

Treasurer MFC

Posted

periodically i am now running into category links like this:

http://www.mysite.com/category/Category.ht...oscSID>=>

 

 

this is a cache problem because that's from the non-stock cache file... i changed my oscsid's to something else... i changed every instance of it throughout every .php file, so i don't think that's it.

 

what could be causing that to output?

i am not using ultimate seo url's

 

and the cache is no longer being written :(

Archived

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

×
×
  • Create New...