Forums / Templates, Stylesheets, Page Layout / Redirect if Shopping Cart is Empty

Redirect if Shopping Cart is Empty

Locked

Views: 2,043

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
7 Aug 2007, 8:32 PM
#1
robgnyc avatar

robgnyc

New Zenner

Join Date:
Jul 2007
Posts:
7
Plugin Contributions:
0

Redirect if Shopping Cart is Empty

Due to some customization issues, my product description pages sit outside of Zen Cart. I go into zen cart just at the point where the user chooses the product adds to their cart. All the products are in zen cart, just the description pages sit outside of it.

If the user removes everything from their cart, I need to re-direct back to my non-Zen site.

Is there a way to over-ride the action for an empty cart and just redirect to a static page outside of Zen Cart?

I'm very familiar with PHP and MySQL.

7 Aug 2007, 8:48 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Redirect if Shopping Cart is Empty

robgnyc:

Is there a way to over-ride the action for an empty cart and just redirect to a static page outside of Zen Cart?

I'm very familiar with PHP and MySQL.

Sure, just add a PHP header redirect in the /includes/modules/pages/shopping_cart/header_php.php if the $_SESSION['cart']->count_contents() is 0.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Aug 2007, 9:50 PM
#3
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,682
Plugin Contributions:
0

Re: Redirect if Shopping Cart is Empty

If you don't mind me asking - What is it about your product descriptions that aren't possible from within Zen Cart?

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

8 Aug 2007, 12:11 AM
#4
robgnyc avatar

robgnyc

New Zenner

Join Date:
Jul 2007
Posts:
7
Plugin Contributions:
0

Re: Redirect if Shopping Cart is Empty

Kim:

If you don't mind me asking - What is it about your product descriptions that aren't possible from within Zen Cart?

Well I have a 4 basic products (categories really) which can be mens or womens, can be one of three levels and each product has 7 different file formats as options. Each file format has between 3 and 6 downloadable files attached to it.

The way I want it to display is to have a product summary that applies to every product and level and then a nice way of choosing which level, gender and file type you want.

I'm sure it is possible within zen cart but being a relatively new user, I found it very difficult to figure out how to set up this type of product and I was fighting the system more than having it work for me. The matrix of attributes required for this type of thing was just too much.

Handling much of the product stuff outside of the system and then jumping in only for the shopping cart functionality seemed a much better solution after a few days of banging my head against the wall. I combined this with some dynamic PHP/MySQL stuff to access the products database on my own and came up with a relatively effective solution that met the clients needs without eating too much of my time.

8 Aug 2007, 12:31 AM
#5
robgnyc avatar

robgnyc

New Zenner

Join Date:
Jul 2007
Posts:
7
Plugin Contributions:
0

Re: Redirect if Shopping Cart is Empty

DrByte:

Sure, just add a PHP header redirect in the /includes/modules/pages/shopping_cart/header_php.php if the $_SESSION['cart']->count_contents() is 0.

Thanks so much. That works perfectly.

12 Nov 2007, 11:16 PM
#6
smallarmsdealer avatar

smallarmsdealer

New Zenner

Join Date:
Oct 2007
Posts:
16
Plugin Contributions:
0

Re: Redirect if Shopping Cart is Empty

For those of us who aren't sure on what PHP to write to accomplish this...can you give an example? I'm currently facing the same issue.

Perhaps somewhere around here in header_php.php?

$flagHasCartContents = ($_SESSION['cart']->count_contents() > 0);

Just not sure on how to go about the if then else here :-( Still learning.