Layered nav dropdowns

This commit is contained in:
Mike Jolley 2012-02-08 10:51:39 +00:00
parent 1dd988075a
commit 31ae4beed3
2 changed files with 16 additions and 17 deletions

View File

@ -88,11 +88,12 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
* Get dimensions fix
* Add order item error fix
* Made slug non-required on add attribute form
* Other minor fixes
* Fixed sharethis code
* Added sharedaddy support
* Option to require login to download files
* Option to display layered nav as a dropdown
* woocommerce_nocache function for cart/checkout/myaccount pages which need to be dynamic
* Other minor fixes
= 1.4.1 - 01/02/2012 =
* Depreciated tax class fix

View File

@ -174,32 +174,30 @@ class WooCommerce_Widget_Layered_Nav extends WP_Widget {
echo $before_widget . $before_title . $title . $after_title;
if ($display_type=='dropdown') {
$taxonomy_filter = str_replace('pa_', '', $taxonomy);
$found = true;
echo '<select id="dropdown_layered_nav_'.$taxonomy.'">';
echo '<select id="dropdown_layered_nav_'.$taxonomy_filter.'">';
echo '<option>'. sprintf( __('Any %s', 'woocommerce'), $taxonomy ) .'</option>';
echo '<option value="">'. sprintf( __('Any %s', 'woocommerce'), $woocommerce->attribute_label( $taxonomy ) ) .'</option>';
foreach ($terms as $term) {
echo '<option>'.$term->name.'</option>';
echo '<option value="'.$term->term_id.'" '.selected( (isset($_GET['filter_'.$taxonomy_filter])) ? $_GET['filter_'.$taxonomy_filter] : '' , $term->term_id, false).'>'.$term->name.'</option>';
}
echo '</select>';
?>
<script type='text/javascript'>
/* <![CDATA[ */
var dropdown = document.getElementById("dropdown_layered_nav_<?php echo $taxonomy; ?>");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value !=='' ) {
location.href = "<?php echo home_url(); ?>/?product_cat="+dropdown.options[dropdown.selectedIndex].value;
}
}
dropdown.onchange = onCatChange;
/* ]]> */
</script>
<?php
$woocommerce->add_inline_js("
jQuery('#dropdown_layered_nav_$taxonomy_filter').change(function(){
location.href = '".home_url(remove_query_arg('filter_' . $taxonomy_filter, add_query_arg('filtering', '1')))."&filter_$taxonomy_filter=' + jQuery('#dropdown_layered_nav_$taxonomy_filter').val();
});
");
} else {