<?php
global $wpsc_query;
if(get_option('permalink_structure')){
$sep = '?';
if(isset($wpsc_query->query_vars['wpsc_product_category']))
$page_url = get_permalink(wpec_get_the_post_id_by_shortcode('[productspage]')) . $wpsc_query->query_vars['wpsc_product_category'] . '/';
else
$page_url = get_permalink(wpec_get_the_post_id_by_shortcode('[productspage]')) . $wpsc_query->query_vars['wpsc_product_category'];
}else{
$sep = '&';
if(isset($_GET['wpsc_product_category']))
$page_url = get_bloginfo('url') . '?wpsc_product_category=' . $wpsc_query->query_vars['wpsc_product_category'];
else
$page_url = get_permalink(wpec_get_the_post_id_by_shortcode('[productspage]'));
}
$gift = ((!empty($_GET['gift']) && ($_GET['gift'] != 'all')) ? $_GET['gift'] .',' : '');
$gift_slug = (($_GET['gift'] == 'all') ? 'gift=all' : ((!empty($_GET['gift'])) ? 'gift=' . substr($gift, 0, -1) . '' : '' ) );
?>
<h1 class="menu-title">TYPE</h1>
<input type="hidden" name="gift" value="<?php echo $_GET['region']; ?>"/>
<?php
$i=1;
$terms_gift = get_terms("wpsc_gift_type", array('hide_empty' => 0, 'orderby' => 'term_group'));
if (count($terms_gift) > 0) { ?>
<ul>
<li class="<?php echo (($_GET['gift'] == 'all') ? 'active' : ''); ?>">
<a href="<?php echo $page_url; ?><?php echo $sep; ?>gift=all">
<input onclick="window.location='<?php echo $page_url; ?><?php echo $sep; ?>gift=all'" type="checkbox" <?php echo (($_GET['gift'] == 'all') ? 'checked=""' : ''); ?> class="checkbox"/>
All</a>
</li>
<?php
$gift_value = explode(',', $gift);
foreach ($terms_gift as $term_g) {
if(in_array($term_g->slug, $gift_value)){
$term_slug_g = '';
$gift_value_str = $gift_value;
$key_g = array_search($term_g->slug, $gift_value_str);
unset($gift_value_str[$key_g]);
$gift_value_str = implode(',', $gift_value_str);
$gift_value_str = substr($gift_value_str, 0, -1);
?>
<li class="active sp-sub-fields ">
<a href="<?php echo $page_url; ?><?php echo $sep; ?><?php echo ((empty($gift_value_str)) ? '' : 'gift=' ) ?><?php echo $gift_value_str .''. $term_slug_g; ?>">
<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"/>
<?php echo $term_g->name; ?></a>
</li>
<?php
} else {
$term_slug_g = $term_g->slug;
?>
<li class="sp-sub-fields ">
<a href="<?php echo $page_url; ?><?php echo $sep; ?>gift=<?php echo $gift .''. $term_slug_g; ?>">
<input onclick="window.location='<?php echo $page_url; ?><?php echo $sep; ?>gift=<?php echo $gift .''. $term_slug_g; ?>'" type="checkbox" class="checkbox"/>
<span class="sp-price"><?php echo $term_g->name; ?></span></a>
</li>
<?php
} ?>
<?php
$i++;
} ?>
</ul>
<?php
}
?>