Forums / Templates, Stylesheets, Page Layout / On Hover Cart Summary

On Hover Cart Summary

Started by matthew_kin on 15 Mar 2015, 11:01 PM · Views: 944

Results 1 to 4 of 4
15 Mar 2015, 11:01 PM
#1
matthew_kin avatar

matthew_kin

New Zenner

Join Date:
Feb 2015
Location:
Gloucestershire
Posts:
24
Plugin Contributions:
0

On Hover Cart Summary

Hi

I am creating a custom template, almost finished.

As part of this i want to create a cart summary.

Currently i have a cart symbol, checkout button and items in cart total all working alongside the ez pages navbar.

I would like to show a cart summary (qty item title, model price and total) like a mini shopping cart summary when the above cart symbol is hovered.

So far i have this working to an extent.

I copied the tpl_shopping_cart_deafult to the div in the header which i want to show when hovered. All working fine.

However unless i am actually on the shopping cart page this shows as no items in the cart, where if i navigate to the cart page and then hover it shows exactly the same in the summary window when hovered.

How do i get this to display when i am not just on the shopping cart page?

Sorry no link developing via localhost.

16 Mar 2015, 3:15 PM
#2
matthew_kin avatar

matthew_kin

New Zenner

Join Date:
Feb 2015
Location:
Gloucestershire
Posts:
24
Plugin Contributions:
0

Re: On Hover Cart Summary

Still not having much luck with this.

Got the below code showing how i would like when hovered on the shopping cart page however when i navigate away from this page the cart says the cart is emty.

<div id="cartSummary">
  <?php
  if ($_SESSION[$flagHasCartContents] or $flagHasCartContents) {
?>

<?php
  if ($_SESSION['cart']->count_contents() > 0) {
?>

<?php
  }
?>

<?php if ($messageStack->size('shopping_cart') > 0) echo $messageStack->output('shopping_cart'); ?>

<?php echo zen_draw_form('cart_quantity', zen_href_link(FILENAME_SHOPPING_CART, 'action=update_product', $request_type)); ?>

<?php  if ($flagAnyOutOfStock) { ?>

<?php    if (STOCK_ALLOW_CHECKOUT == 'true') {  ?>

<div class="messageStackError"><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></div>

<?php    } else { ?>
<div class="messageStackError"><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></div>

<?php    } //endif STOCK_ALLOW_CHECKOUT ?>
<?php  } //endif flagAnyOutOfStock ?>

<table  border="0" width="100%" cellspacing="0" cellpadding="0" id="cartContentsDisplay">
     <tr class="tableHeading">
        <th scope="col" id="scQuantityHeading"><?php echo TABLE_HEADING_QUANTITY; ?></th>
        <th scope="col" id="scProductsHeading"><?php echo TABLE_HEADING_PRODUCTS; ?></th>
        <th scope="col" id="scUnitHeading"><?php echo TABLE_HEADING_PRICE; ?></th>        
     </tr>
         <!-- Loop through all products /-->
<?php
  foreach ($productArray as $product) {
?>
     <tr class="<?php echo $product['rowClass']; ?>">
       <td class="cartQuantity">
<?php
  echo $product['showFixedQuantityAmount'] . '<br /><span class="alert bold">' . $product['flagStockCheck'] . '</span><br /><br />' . $product['showMinUnits'];
  ?>
       </td>
       </td>
       <td class="cartProductDisplay">
<a href="<?php echo $product['linkProductsName']; ?>"><span id="cartImage" class="back"><?php echo $product['productsImage']; ?></span><span id="cartProdTitle"><?php echo $product['productsName'] . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>'; ?></span></a>
<br class="clearBoth" />


<?php
  echo $product['attributeHiddenField'];
  if (isset($product['attributes']) && is_array($product['attributes'])) {
  echo '<div class="cartAttribsList">';
  echo '<ul>';
    reset($product['attributes']);
    foreach ($product['attributes'] as $option => $value) {
?>

<li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']); ?></li>

<?php
    }
  echo '</ul>';
  echo '</div>';
  }
?>
       </td>
       <td class="cartUnitDisplay"><?php echo $product['productsPriceEach']; ?></td>
       </td>
     </tr>
<?php
  } // end foreach ($productArray as $product)
?>
       <!-- Finished loop through all products /-->
      </table>

<div id="cartSubTotal"><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $_SESSION['cart']->show_Total(); ?></div>
<br class="clearBoth" />

<!--bof shopping cart buttons-->
<div class="buttonRow forward"><?php echo '<a href="' . zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_CHECKOUT, BUTTON_CHECKOUT_ALT) . '</a>'; ?></div>


<div class="buttonRow back"><?php echo '<a href="index.php?main_page=shopping_cart">' . zen_image_button(BUTTON_IMAGE_VIEW_CART, BUTTON_VIEW_CART_ALT) . '</a>'; ?></div>
<br />
<br />
<!--eof shopping cart buttons-->
</form>

<br class="clearBoth" />

<?php
  } else {
?>

<h2 id="cartEmptyText"><?php echo TEXT_CART_EMPTY; ?></h2>

<?php
$show_display_shopping_cart_empty = $db->Execute(SQL_SHOW_SHOPPING_CART_EMPTY);

while (!$show_display_shopping_cart_empty->EOF) {
?>

<?php
  $show_display_shopping_cart_empty->MoveNext();
} // !EOF
?>
<?php
  }
?>
          </div>

This is what i have so far but only shows content when hovered on cart summary page.

Added the below in:

  <?php
  if ($_SESSION[$flagHasCartContents] or $flagHasCartContents) {
?>

Which now shows the table and stops the cart is empty message when i navigate away from the cart summary page.

However the table is not populated so guessing i need to add $_SESSION around the product name and quantity somewhere however no matter what i try nothing works.

Really stuck here.

17 Mar 2015, 4:44 PM
#3
matthew_kin avatar

matthew_kin

New Zenner

Join Date:
Feb 2015
Location:
Gloucestershire
Posts:
24
Plugin Contributions:
0

Re: On Hover Cart Summary

Right i have realised certain variables are only being loaded once on the cart page.

These come from modules/pages/shopping_cart/header_php.php

I copied these into my header template and low and behold this made the hover box work as it should.

However will there be any detrimental effects of me having this file in the header template?

Or is there a way i can load this file all the time?

19 Mar 2015, 10:21 AM
#4
matthew_kin avatar

matthew_kin

New Zenner

Join Date:
Feb 2015
Location:
Gloucestershire
Posts:
24
Plugin Contributions:
0

Re: On Hover Cart Summary

Any idea guys?

Just need to finish these last couple of things then will be able to get the databases fully populated and get the site uploaded.