2011-12-11 01:10:24 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2013-02-10 17:32:45 +00:00
|
|
|
* Show options for ordering
|
2012-08-14 18:05:45 +00:00
|
|
|
*
|
|
|
|
* @author WooThemes
|
|
|
|
* @package WooCommerce/Templates
|
2012-12-03 19:19:58 +00:00
|
|
|
* @version 2.0.0
|
2011-12-11 01:10:24 +00:00
|
|
|
*/
|
2012-10-15 10:57:58 +00:00
|
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
|
|
|
2013-01-07 14:17:41 +00:00
|
|
|
global $woocommerce, $wp_query;
|
2012-10-14 12:06:37 +00:00
|
|
|
|
2013-01-12 15:12:17 +00:00
|
|
|
if ( 1 == $wp_query->found_posts || ! woocommerce_products_will_display() )
|
2012-10-14 12:06:37 +00:00
|
|
|
return;
|
2011-12-11 01:10:24 +00:00
|
|
|
?>
|
2013-01-12 10:53:08 +00:00
|
|
|
<form class="woocommerce-ordering" method="get">
|
|
|
|
<select name="orderby" class="orderby">
|
2011-12-11 01:10:24 +00:00
|
|
|
<?php
|
2012-10-14 12:06:37 +00:00
|
|
|
$catalog_orderby = apply_filters( 'woocommerce_catalog_orderby', array(
|
2013-01-12 10:53:08 +00:00
|
|
|
'menu_order' => __( 'Default sorting', 'woocommerce' ),
|
|
|
|
'popularity' => __( 'Sort by popularity', 'woocommerce' ),
|
|
|
|
'rating' => __( 'Sort by average rating', 'woocommerce' ),
|
|
|
|
'date' => __( 'Sort by newness', 'woocommerce' ),
|
|
|
|
'price' => __( 'Sort by price: low to high', 'woocommerce' ),
|
|
|
|
'price-desc' => __( 'Sort by price: high to low', 'woocommerce' )
|
2012-10-14 12:06:37 +00:00
|
|
|
) );
|
2011-12-11 01:10:24 +00:00
|
|
|
|
2013-01-12 10:53:08 +00:00
|
|
|
if ( get_option( 'woocommerce_enable_review_rating' ) == 'no' )
|
|
|
|
unset( $catalog_orderby['rating'] );
|
|
|
|
|
2012-08-14 18:05:45 +00:00
|
|
|
foreach ( $catalog_orderby as $id => $name )
|
2013-01-12 10:53:08 +00:00
|
|
|
echo '<option value="' . esc_attr( $id ) . '" ' . selected( $orderby, $id, false ) . '>' . esc_attr( $name ) . '</option>';
|
2011-12-11 01:10:24 +00:00
|
|
|
?>
|
|
|
|
</select>
|
2013-01-12 12:24:24 +00:00
|
|
|
<?php
|
|
|
|
// Keep query string vars intact
|
2013-01-12 15:08:23 +00:00
|
|
|
foreach ( $_GET as $key => $val ) {
|
|
|
|
if ( 'orderby' == $key )
|
2013-01-12 12:24:24 +00:00
|
|
|
continue;
|
|
|
|
echo '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $val ) . '" />';
|
|
|
|
}
|
|
|
|
?>
|
2012-10-14 12:06:37 +00:00
|
|
|
</form>
|