Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2012
    Location
    California
    Posts
    21
    Plugin Contributions
    0

    help question Display Shopping Cart Summary In Header Issues

    I am trying to display a summary of the shopping cart in a header drop down menu (tpl_header.php). I have searched high and low for this capability. I even tried installing the "Cart Summary Sidebox" plugin, but I couldn't get it to work. I am not sure if it would suit my needs if it did work.

    So what I have done is copied the tpl_shopping_cart_default.php code and inserted it into a div in the header drop down menu. I then removed all of the code that I did not need, or think I need. I would remove some code and then upload the file to check if it was broken. If it was broken I would go back and replace the relevant code. The remaining code is below.

    I modified and rearranged the shopping cart summary in the dropdown menu with some divs and css. It looks just how I want, and it is functional. It displays the product name, quantity, unit price, product image and cart subtotal with a view cart button and checkout button.

    The problem is it only shows in the dropdown menu on the shopping cart page. It does not show on any other page. The dropdown works on the other pages but it only displays "TEXT_CART_EMPTY" (without quotation marks).

    I thought that I was onto something good here, but after doing some research I am starting to think that this is a larger php issue. Does this issue need some major php modification or am I missing some minor php code to call the shopping cart contents into the other pages.

    I am using version 1.5.1 with only ZX Slideshow installed.

    Here is the link to my live site http://4twentee.com. Here is a link to a test product to add to the shopping cart to test http://4twentee.com/index.php?main_p...&products_id=3

    Thank you in advance for any assistance.

    The code below is placed in a div in the dropdown menu. I did not include all of the other code from tpl_header.php

    <?php

    ?>

    <div class="header-cart-wrapper">
    <?php

    if ($flagHasCartContents) {

    ?>


    <h1 id="header-cart-title"><?php echo HEADING_TITLE; ?></h1>



    <table border="0" width="100%" cellspacing="0" cellpadding="0" id="cartContentsDisplay">


    <!-- Loop through all products /-->

    <?php

    foreach ($productArray as $product) {

    ?>

    <tr class="<?php echo $product['rowClass']; ?>">

    <td><div class="header-cart-products-name"><a href="<?php echo $product['linkProductsName']; ?>"><span id="cartProdTitle"><?php echo $product['productsName'] . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>'; ?></span></a></div>
    <br />
    <div class="header-cart-item-info">
    <div class="header-cart-item-count ">
    <?php

    if ($product['flagShowFixedQuantity']) {

    echo $product['showFixedQuantityAmount'] . '<br /><span class="alert bold">' . $product['flagStockCheck'] . '</span><br /><br />' . $product['showMinUnits'];

    } else {

    echo $product['showFixedQuantityAmount'] . '<br /><span class="alert bold">' . $product['flagStockCheck'] . '</span><br /><br />' . $product['showMinUnits'];

    }

    ?>
    </div>
    <div class="header-cart-item-spacer">&nbsp;&nbsp;x&nbsp;&nbsp;</div>
    <div class="header-cart-item-cost"><?php echo $product['productsPriceEach']; ?></div>
    </div></td>

    <td><a href="<?php echo $product['linkProductsName']; ?>"><span id="header-cartImage"><?php echo $product['productsImage']; ?></span></a></td>

    </tr>

    <?php

    } // end foreach ($productArray as $product)

    ?>

    <!-- Finished loop through all products /-->

    </table>



    <div id="header-cart-subtotal"><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $cartShowTotal; ?></div>


    <!--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" class="drop">' . zen_image_button(BUTTON_IMAGE_VIEW_CART, BUTTON_VIEW_CART_ALT) . '</a>'; ?></div>


    <!--eof shopping cart buttons-->


    <br class="clearBoth" />

    <!-- ** BEGIN PAYPAL EXPRESS CHECKOUT ** -->

    <?php // the tpl_ec_button template only displays EC option if cart contents >0 and value >0

    if (defined('MODULE_PAYMENT_PAYPALWPP_STATUS') && MODULE_PAYMENT_PAYPALWPP_STATUS == 'True') {

    include(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/paypal/tpl_ec_button.php');

    }

    ?>

    <!-- ** END PAYPAL EXPRESS CHECKOUT ** -->


    <?php

    } else {

    ?>


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


    <?php

    }

    ?>

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Display Shopping Cart Summary In Header Issues

    $flagHasCartContents probably isn't calculated except in the code run on the shopping cart page, hence the symptoms you describe.

    Have you considered one of the many plugins that already does what you're after?
    Here are two that I found with a very quick search:
    http://www.zen-cart.com/downloads.php?do=file&id=990
    http://www.zen-cart.com/downloads.php?do=file&id=336
    .

    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.

  3. #3
    Join Date
    Apr 2012
    Location
    California
    Posts
    21
    Plugin Contributions
    0

    Default Re: Display Shopping Cart Summary In Header Issues

    Dr Byte,

    Thanks for the info. I went with shoppingcart_freeship_header_1_2.

    It has fixed the problem. I am able to see the shopping cart info in the dropdown menu on all pages. It shows cart total, total items, free shipping info, and a checkout button.

    I have been able to remove the free shipping info and add a view cart button. I would like to remove cart total and total items, and add product name (with link), unit cost, product quantity (per item), product image (with link) and subtotal as follows,


    Product Name
    (quantity) x (unit cost) Image

    Subtotal


    I have tried plugging in the different components that I want to change to no avail. I have also searched for info on shopping cart variables. I am able to change the layout just fine with divs and css, I just can't figure out how to modify this piece of php.

    This is the current code that I am trying to modify, replace or change:


    <div id="cartCount">
    <?php
    if ($cart_count) {
    $_SESSION['cart']->get_products();
    $basket_total = $_SESSION['cart']->show_total();
    echo '<span id="cartTotal">' . CART_HEADER_TOTAL . $currencies->format($basket_total) . '</span>' ;
    }
    echo ($cart_count? '<a href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '">':'') . CART_HEADER_IN_CART_PRE . $cart_count . (($cart_count == 1)? CART_HEADER_IN_CART_SINGULAR: CART_HEADER_IN_CART_PLURAL) . ($cart_count? '</a>': '');
    ?>
    </div>



    I am trying to incorporate the following code that includes product name, unit cost, product quantity, product image and subtotal. I see that they are coded differently, the code below is from my initial post (modified tpl_shopping_cart_default.php). Where can I find information on this? Is this straight php? I couldn't find what I was looking for in the forum. I may not know what I am looking for (productsName, showFixedQuantityAmount, productsPriceEach, productsImage, cartShowTotal).

    <td><div class="header-cart-products-name"><a href="<?php echo $product['linkProductsName']; ?>"><span id="cartProdTitle"><?php echo $product['productsName'] . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>'; ?></span></a></div>
    <br />
    <div class="header-cart-item-info">
    <div class="header-cart-item-count ">
    <?php

    if ($product['flagShowFixedQuantity']) {

    echo $product['showFixedQuantityAmount'] . '<br /><span class="alert bold">' . $product['flagStockCheck'] . '</span><br /><br />' . $product['showMinUnits'];

    } else {

    echo $product['showFixedQuantityAmount'] . '<br /><span class="alert bold">' . $product['flagStockCheck'] . '</span><br /><br />' . $product['showMinUnits'];

    }

    ?>
    </div>
    <div class="header-cart-item-spacer">&nbsp;&nbsp;x&nbsp;&nbsp;</div>
    <div class="header-cart-item-cost"><?php echo $product['productsPriceEach']; ?></div>
    </div></td>

    <td><a href="<?php echo $product['linkProductsName']; ?>"><span id="header-cartImage"><?php echo $product['productsImage']; ?></span></a></td>

    <?php

    } // end foreach ($productArray as $product)

    ?>

    <!-- Finished loop through all products /-->

    </table>



    <div id="header-cart-subtotal"><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $cartShowTotal; ?></div>

    ...

    Thanks Again!
    Last edited by jackolive; 19 Dec 2012 at 10:51 AM.

 

 

Similar Threads

  1. Shopping Cart Summary Delete Item Button
    By mattk251285 in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 7 Mar 2016, 10:34 PM
  2. Shopping Cart Summary Sidebox - Product Characters
    By mattk251285 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 6 Dec 2011, 10:56 AM
  3. Shopping Cart Header and contents display problem
    By fastdc5 in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 17 Feb 2009, 10:20 PM
  4. shopping cart line summary won't turn off
    By mezx in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 7 Apr 2008, 11:30 AM
  5. Shopping Cart Summary Sidebox
    By mrmrsg in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 26 Apr 2007, 07:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg