Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 06-17-2009 15:36:41

9000world
Member
From: Denver
Registered: 06-19-2007
Posts: 37
Website

How do I retrieve the number of items in the shopping cart

I'm modifying the top level display skin (skin.php) to display differently if there are items in the shopping cart.

I've tried the following with no joy:

$cart = $this->globals('ecom.cart_contents');
$cartinuse = 0;
if(!(empty($cart))) { $cartinuse = 1; }

Many thanks in advance!

Offline

 

#2 06-17-2009 16:00:44

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: How do I retrieve the number of items in the shopping cart

From the Mini Cart Display XHTML include:

Code:

$mini    = $this->globals('ecom.cart_mini_array');

if (empty($mini['items'])) {

     print '<p>There are no items in your shopping cart.</p>' . $eol;

} else {

     print '<p>There are ' . $mini['items'] . ' items in your shopping cart.</p>' . $eol;

Offline

 

#3 06-17-2009 16:16:54

9000world
Member
From: Denver
Registered: 06-19-2007
Posts: 37
Website

Re: How do I retrieve the number of items in the shopping cart

Strange. I changed the logic to:

$mini = $this->globals('ecom.cart_mini_array');
if(empty($mini['items'])) {
  $cartinuse = 0;
} else {
  $cartinuse = 1;
}

And it returns $cartinuse = 0 whether or not there is something in the cart.

You mention doing this "From the Mini Cart Display XHTML include". I'm sure that it works fine there, but I'm trying to do it from the display skin. Is that a problem?

Offline

 

#4 06-17-2009 16:24:37

dh783
Member
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: How do I retrieve the number of items in the shopping cart

The display skin does not get a copy of the array of items in the cart, it only displays the output of the mini cart script.

John

Last edited by dh783 (06-17-2009 16:25:17)

Offline

 

#5 06-17-2009 16:28:40

9000world
Member
From: Denver
Registered: 06-19-2007
Posts: 37
Website

Re: How do I retrieve the number of items in the shopping cart

Bummer. Thanks for the reply in any case.

Offline

 

#6 06-17-2009 16:59:52

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: How do I retrieve the number of items in the shopping cart

The global should certainly be available in the skin since the skin is almost the very last thing processed when building a page to be displayed.

Offline

 

#7 06-17-2009 17:19:28

dh783
Member
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: How do I retrieve the number of items in the shopping cart

You may have to place this at the end of the mini cart script to pass on the global to the skin.

Code:

$this->globals('ecom.cart_mini_array', $mini);

John

Offline

 

#8 06-17-2009 17:19:53

9000world
Member
From: Denver
Registered: 06-19-2007
Posts: 37
Website

Re: How do I retrieve the number of items in the shopping cart

Ok. Joyfullness finally.

The code in my previous post DOES work in the display skin file, but it depends on the placement of the code snippet.

I suppose it was obvious to everyone else (and should have been to me) that the snippet has to be placed AFTER:

<?php /* PHP FUNCTION */
          /* Include the minicart namespace. */
         $skinfunc->namespace($app_id,'minicart'); ?>

The $mini hash hasn't been initialized before this point in the php file.

Hopefully this will help someone else as well.

Thanks for the replys!

Offline

 

Board footer