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.
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
From the Mini Cart Display XHTML include:
$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
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
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
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
You may have to place this at the end of the mini cart script to pass on the global to the skin.
$this->globals('ecom.cart_mini_array', $mini);John
Offline
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