Replicating Gridmarket's Sliding Cart Header


I'm trying to replicate the sliding panel that reveals the shopping cart when "view cart" is clicked in the header of the gridmarket theme.

I've got everything working just fine except for one minor detail. Where it displays "cart: 0 item(s)", it remains displaying zero until you click to another page or the current page is refreshed. products which are added to the cart appear instantly and are added perfectly, it's just the jquery/ajax auto-update for the number of items in the cart that isn't functioning.

You can see it in action here:

Here is my header.php code

<div id="top" class="header-wrapper">
  <div id="header-basket">
    <?php if ( class_exists( 'MarketPress' ) ) {
    <div id="cart-contents">
      <?php _e( 'Cart:', TEMPLATE_DOMAIN ) ?>
      <span><?php echo sprintf(__('%s item(s)', TEMPLATE_DOMAIN ), mp_items_count_in_cart()); ?></span></div>
    <div id="mp-cartsmall">
      <div id="toggle"> <a id="open" class="open button" href="#">
        <?php _e( 'View Cart', TEMPLATE_DOMAIN ) ?>
        </a> <a id="close" style="display: none;" class="close button" href="#">
        <?php _e( 'Hide Cart', TEMPLATE_DOMAIN ) ?>
        </a> </div>
    <?php } ?>
    <div id="search-bar">
      <?php get_search_form(); ?>
    <div class="clear"></div>
<?php if ( class_exists( 'MarketPress' ) ) {
					// sliding shopping cart
<div id="panel">
  <div id="panel-inner" class="mp_cart_widget"> <?php echo mp_show_cart('widget'); ?>
    <div class="clear"></div>
  <div class="clear"></div>
<?php } ?>

Many thanks

  • DavidM
    • DEV MAN’s Mascot

    Hi quango and welcome to WPMU DEV!

    You're definitely free to use any of the theme and plugin code elsewhere but we can't really support that usage here in the forums, as it would be incredibly time-consuming trying to troubleshoot so many items.

    That said, can you confirm that jQuery is getting loaded before all of this?


  • quango
    • Flash Drive

    Ok, that's understandable but in essence, I'm still using marketpress with the gridmarket theme, I've just made a few modifications to better suit my layout. But thank you for still offering to help on this matter.

    Yes jQuery is being loaded because the sliding cart does work: it slides. And when I add an item to the cart, it appears there instantly. It's ONLY the item count that doesn't change. Have a look at the link, add the item to the cart and you'll see what I mean.

    Thank you

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.