Created
July 16, 2013 15:13
-
-
Save clifgriffin/6009636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('wp', 'handle_advanced_filter_collection'); | |
function handle_advanced_filter_collection() { | |
if( is_catalog_frontpage() ) { | |
if(isset($_REQUEST['bc'])) { | |
$bc = $_REQUEST['bc']; | |
shopp('storefront','category',"slug=$bc&load=true"); | |
$title = '&title=' . shopp('collection','get-name'); | |
} elseif( !isset($_REQUEST['search']) ) { | |
$title = "&title=Gallery Products"; | |
} | |
$search = ''; | |
$searching = false; | |
if(isset($_REQUEST['search'])) { | |
$searching = true; | |
$search = $_REQUEST['search']; | |
} | |
shopp('catalog','advanced-filters-collection',"load=true&search=$search" . $title); | |
shopp('collection','load-products'); | |
shopp('collection','total'); // this works | |
if( shopp('collection','get-total') === 1 && $searching ) { | |
while( shopp('collection','products') ) | |
{ | |
wp_redirect( shopp('product', 'get-url') ); | |
exit(); | |
} | |
} | |
} | |
} | |
// CATALOG.PHP -- none of the references to collection.total work, but the product loop shows the expected results // | |
<?php get_header(); ?> | |
<div class="container_12"> | |
<div class="grid_12 search-tabs-filter-link"> | |
<?php if( !empty($search) && !isset($_REQUEST['advanced_filters']) ): ?> | |
<?php $class = 'hidden'; ?> | |
<a href="#" id="show_filters_link">Showing <?php shopp('collection','total'); ?> products. Click here to narrow your search.</a> | |
<script> | |
jQuery("#show_filters_link").click(function(e) { | |
jQuery("div.search-tabs").slideDown(300); | |
jQuery("div.search-tabs-filter-link").slideUp(300); | |
e.preventDefault(); | |
}); | |
</script> | |
<?php else: ?> | |
<span>Narrow your search using one or more of the keywords or filters below.</span> | |
<?php endif; ?> | |
</div> | |
</div> | |
<div class="search-tabs <?php echo $class; ?>"> | |
<div class="search-tabs-title"> | |
<div class="container_12"> | |
<ul class="basic-tabs grid_12"> | |
<li class="active grid_3 alpha"><a href="#category" data-toggle="tab">Category</a></li> | |
<li class="grid_3"><a href="#price" data-toggle="tab">Price</a></li> | |
<li class="grid_3"><a href="#color" data-toggle="tab">Color</a></li> | |
<li class="grid_3 omega"><a href="#size" data-toggle="tab">Size</a></li> | |
</ul> | |
</div> | |
</div> | |
<div class="container_12"> | |
<div class="tab-content grid_12"> | |
<div class="tab-pane active" id="category"> | |
<?php shopp('storefront','show-advanced-filters','taxonomy=shopp_tag'); ?> | |
<div class="clear"></div> | |
</div> | |
<div class="tab-pane" id="price"> | |
<?php shopp('storefront','show-advanced-filters','taxonomy=price'); ?> | |
<div class="clear"></div> | |
</div> | |
<div class="tab-pane" id="color"> | |
<?php shopp('storefront','show-advanced-filters','taxonomy=shopp_color'); ?> | |
<div class="clear"></div> | |
</div> | |
<div class="tab-pane" id="size"> | |
<?php shopp('storefront','show-advanced-filters','taxonomy=shopp_print_size'); ?> | |
<div class="clear"></div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="gray-container"> | |
<div class="gray-title"> | |
<div class="container_12"> | |
<div class="grid_12"> | |
<h3>Displaying: <span><?php shopp('collection','total'); ?> products</span></h3> | |
<?php shopp('storefront','show-advanced-filters-toggles'); ?> | |
</div> | |
</div> | |
</div> | |
<div class="content"> | |
<div class="container_12"> | |
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> | |
<?php the_content(); ?> | |
<?php endwhile; endif; ?> | |
</div> | |
</div> | |
</div> | |
<?php get_template_part('content', 'social-bar'); ?> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment