Tuesday, March 12, 2013

How to Show/Hide Wpcommerce Shopping Cart Widget

Using jQuery you can very quickly setup functionality to show & hide the cart widget in wpcommerce. Just add the below snippet to the wpsc-cart_widget.php in your template override file at the top. Blam, done.

 When the customer clicks on add to cart button, the widget will show and be updated with the new price. When the user clicks clear cart, it hides.

Simple. The second part automatically hides the cart when its empty. This could also be done with CSS.

<script type="text/javascript">
jQuery(function(){
    
            
        jQuery('.wpsc_buy_button').click(function(){
            jQuery('.widget_wpsc_shopping_cart').show();
        });
        jQuery('.emptycart').click(function(){
            jQuery('.widget_wpsc_shopping_cart').hide();
        });
        
})
</script>


<?php if(wpsc_cart_item_count() <= 0)
{ ?>
<script type="text/javascript">
jQuery(function(){
    
    jQuery('.widget_wpsc_shopping_cart').hide();
  
})
</script>
<?php } ?>


Stumble Upon CodePyro

1 comment:

Anonymous said...

As well as brash Large Boom while offering some rolex replica uk unobtrusive. From 45mm broad having a easy day rolex replica uk, it is unfussy, readable, as well as fairly good rolex replica sale, for me. The actual debut from the replica watches Traditional Blend Titanium watch arrived this year. It is fascinating to notice replica watches arrived on the scene 5 many rolex replica sale following the rolex replica sale Boom an indicator which replica watches sale understood that.

Post a Comment