Advertisement
nxtstudios

filter gifts

Nov 30th, 2011
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. <?php
  2. global $wpsc_query;
  3.  
  4. if(get_option('permalink_structure')){
  5. $sep = '?';
  6. if(isset($wpsc_query->query_vars['wpsc_product_category']))
  7. $page_url = get_permalink(wpec_get_the_post_id_by_shortcode('[productspage]')) . $wpsc_query->query_vars['wpsc_product_category'] . '/';
  8. else
  9. $page_url = get_permalink(wpec_get_the_post_id_by_shortcode('[productspage]')) . $wpsc_query->query_vars['wpsc_product_category'];
  10. }else{
  11. $sep = '&';
  12. if(isset($_GET['wpsc_product_category']))
  13. $page_url = get_bloginfo('url') . '?wpsc_product_category=' . $wpsc_query->query_vars['wpsc_product_category'];
  14. else
  15. $page_url = get_permalink(wpec_get_the_post_id_by_shortcode('[productspage]'));
  16. }
  17.  
  18.  
  19. $gift = ((!empty($_GET['gift']) && ($_GET['gift'] != 'all')) ? $_GET['gift'] .',' : '');
  20. $gift_slug = (($_GET['gift'] == 'all') ? 'gift=all' : ((!empty($_GET['gift'])) ? 'gift=' . substr($gift, 0, -1) . '' : '' ) );
  21.  
  22. ?>
  23. <h1 class="menu-title">TYPE</h1>
  24. <input type="hidden" name="gift" value="<?php echo $_GET['region']; ?>"/>
  25. <?php
  26. $i=1;
  27. $terms_gift = get_terms("wpsc_gift_type", array('hide_empty' => 0, 'orderby' => 'term_group'));
  28. if (count($terms_gift) > 0) { ?>
  29. <ul>
  30. <li class="<?php echo (($_GET['gift'] == 'all') ? 'active' : ''); ?>">
  31. <a href="<?php echo $page_url; ?><?php echo $sep; ?>gift=all">
  32. <input onclick="window.location='<?php echo $page_url; ?><?php echo $sep; ?>gift=all'" type="checkbox" <?php echo (($_GET['gift'] == 'all') ? 'checked=""' : ''); ?> class="checkbox"/>
  33. All</a>
  34. </li>
  35. <?php
  36. $gift_value = explode(',', $gift);
  37. foreach ($terms_gift as $term_g) {
  38. if(in_array($term_g->slug, $gift_value)){
  39. $term_slug_g = '';
  40. $gift_value_str = $gift_value;
  41.  
  42. $key_g = array_search($term_g->slug, $gift_value_str);
  43. unset($gift_value_str[$key_g]);
  44. $gift_value_str = implode(',', $gift_value_str);
  45.  
  46. $gift_value_str = substr($gift_value_str, 0, -1);
  47. ?>
  48. <li class="active sp-sub-fields ">
  49. <a href="<?php echo $page_url; ?><?php echo $sep; ?><?php echo ((empty($gift_value_str)) ? '' : 'gift=' ) ?><?php echo $gift_value_str .''. $term_slug_g; ?>">
  50. <input onclick="window.location='<?php echo $page_url; ?><?php echo $sep; ?><?php echo ((empty($gift_value_str)) ? '' : 'gift=' ) ?><?php echo $gift_value_str .''. $term_slug_g; ?>'" type="checkbox" checked="" class="checkbox"/>
  51. <?php echo $term_g->name; ?></a>
  52. </li>
  53. <?php
  54. } else {
  55. $term_slug_g = $term_g->slug;
  56. ?>
  57. <li class="sp-sub-fields ">
  58. <a href="<?php echo $page_url; ?><?php echo $sep; ?>gift=<?php echo $gift .''. $term_slug_g; ?>">
  59. <input onclick="window.location='<?php echo $page_url; ?><?php echo $sep; ?>gift=<?php echo $gift .''. $term_slug_g; ?>'" type="checkbox" class="checkbox"/>
  60. <span class="sp-price"><?php echo $term_g->name; ?></span></a>
  61. </li>
  62. <?php
  63. } ?>
  64. <?php
  65. $i++;
  66. } ?>
  67. </ul>
  68. <?php
  69. }
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement