Advertisement
webaware

wp-e-commerce display ‘go to basket’ link dynamically

Apr 9th, 2012
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. * generate the HTML always, just hide it if cart count is 0
  4. * then it will display when the page refreshes, and also you can
  5. * activate it easily from JavaScript
  6. * NB: replace "some-handle" with an ID that is meaningful to you!
  7. */
  8. ?>
  9. <span id="some-handle" style="<?php if (wpsc_cart_item_count() > 0) echo 'display:none;'; ?>">
  10. <a target="_parent" href="<?php echo get_option('shopping_cart_url'); ?>" title="<?php _e('Checkout', 'wpsc'); ?>" class="gocheckout_dyn"><?php _e('Checkout &rarr;', 'wpsc'); ?></a>
  11. </span>
  12.  
  13. <?php
  14. /**
  15. * action hook for wp-e-commerce to provide our own AJAX cart updates
  16. * EDIT: place this code into your functions.php, not your template file
  17. */
  18. function theme_cart_update() {
  19.     $cart_count = wpsc_cart_item_count();
  20.     if ($cart_count > 0)
  21.     echo "jQuery('#some-handle').fadeIn();\n";
  22. }
  23. add_action('wpsc_alternate_cart_html', 'theme_cart_update');
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement