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 } ?>

2 comments:
“This blog looks like a useful resource for developers and tech enthusiasts, offering clear insights and practical coding content. The posts are engaging and well‑structured, making complex topics easier to understand. Great work — keep sharing more!”
IT Jobs Without Coding – Complete Beginner Guide
Really enjoyed this post! It’s always great to come across content that is both informative and easy to understand. Keep up the great work!UI/UX design course syllabus
Post a Comment