Exemplo n.º 1
0
/**
 * Applies current filters to the query
 *
 * @param object $query
 */
function apply_product_filters($query)
{
    if (!is_admin() && !is_home_archive($query) && $query->is_main_query() && is_product_filters_active() && (is_ic_product_listing($query) || is_ic_taxonomy_page())) {
        if (is_product_filter_active('product_category')) {
            $category_id = get_product_filter_value('product_category');
            $taxonomy = get_current_screen_tax();
            $taxquery = array(array('taxonomy' => $taxonomy, 'terms' => $category_id));
            $query->set('tax_query', $taxquery);
        }
        if (is_product_filter_active('min-price') || is_product_filter_active('max-price')) {
            $metaquery = array();
            $min_price = get_product_filter_value('min-price');
            if (!empty($min_price)) {
                $metaquery[] = array('key' => '_price', 'compare' => '>=', 'value' => $min_price, 'type' => 'NUMERIC');
            }
            $max_price = get_product_filter_value('max-price');
            if (!empty($max_price)) {
                $metaquery[] = array('key' => '_price', 'compare' => '<=', 'value' => $max_price, 'type' => 'NUMERIC');
            }
            $query->set('meta_query', $metaquery);
        }
        do_action('apply_product_filters', $query);
    }
}
Exemplo n.º 2
0
}
if ((is_tax() || is_search() || !is_ic_only_main_cats()) && more_products()) {
    do_action('before_product_list', $archive_template, $multiple_settings);
    $product_list = '';
    while (have_posts()) {
        the_post();
        $product_list .= get_catalog_template($archive_template, $post);
    }
    $product_list = apply_filters('product_list_ready', $product_list, $archive_template, 'auto_listing');
    echo '<div class="product-list responsive ' . $archive_template . ' ' . product_list_class($archive_template) . '">' . $product_list . '</div><span class="clear"></span>';
} else {
    if (!is_product_filters_active() && is_search() && !more_products()) {
        echo '<p>' . __('Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'ecommerce-product-catalog') . '</p>';
        product_search_form();
    } else {
        if (is_product_filters_active() && !more_products()) {
            show_product_sort_bar();
            $filters = get_active_product_filters();
            if (isset($_GET['s'])) {
                $filters[] = 's';
            }
            echo '<p>' . sprintf(__('Sorry, but nothing matched your search terms. Please try again with some different options or %sreset filters%s.', 'ecommerce-product-catalog'), '<a href="' . esc_url(remove_query_arg($filters)) . '">', '</a>') . '</p>';
        }
    }
}
?>
	</div>
</article><?php 
do_action('product_listing_end', $archive_template, $multiple_settings);
if (isset($is_home)) {
    wp_reset_query();
Exemplo n.º 3
0
/**
 * Checks if sort drop down should be shown
 *
 * @global int $product_sort
 * @global object $wp_query
 * @return boolean
 */
function is_product_sort_bar_active()
{
    global $product_sort, $wp_query;
    if (get_integration_type() != 'simple' && (is_product_filters_active() || isset($product_sort) && $product_sort == 1 || !is_ic_shortcode_query() && ($wp_query->max_num_pages > 1 || $wp_query->found_posts > 0))) {
        return true;
    }
    return false;
}
/**
 * Generates product listing products
 *
 * @param type $archive_template
 * @param type $multiple_settings
 */
function ic_product_listing_products($archive_template, $multiple_settings)
{
    global $post, $ic_is_home;
    if (is_home_archive() || !more_products() && is_custom_product_listing_page()) {
        if (get_query_var('paged')) {
            $paged = get_query_var('paged');
        } elseif (get_query_var('page')) {
            $paged = get_query_var('page');
        } else {
            $paged = 1;
        }
        $args = apply_filters('home_product_listing_query', array('post_type' => 'al_product', 'posts_per_page' => $multiple_settings['archive_products_limit'], 'paged' => $paged));
        query_posts($args);
        $ic_is_home = 1;
    }
    if ((is_tax() || is_search() || !is_ic_only_main_cats() || is_product_filters_active()) && more_products()) {
        do_action('before_product_list', $archive_template, $multiple_settings);
        $product_list = '';
        while (have_posts()) {
            the_post();
            $product_list .= get_catalog_template($archive_template, $post);
        }
        $product_list = apply_filters('product_list_ready', $product_list, $archive_template, 'auto_listing');
        echo '<div class="product-list responsive ' . $archive_template . ' ' . product_list_class($archive_template) . '">' . $product_list . '</div><span class="clear"></span>';
    } else {
        if (!is_product_filters_active() && is_search() && !more_products()) {
            echo '<p>' . __('Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'ecommerce-product-catalog') . '</p>';
            product_search_form();
        } else {
            if (is_product_filters_active() && !more_products()) {
                show_product_sort_bar();
                $filters = get_active_product_filters();
                if (isset($_GET['s'])) {
                    $filters[] = 's';
                }
                echo '<p>' . sprintf(__('Sorry, but nothing matched your search terms. Please try again with some different options or %sreset filters%s.', 'ecommerce-product-catalog'), '<a href="' . esc_url(remove_query_arg($filters)) . '">', '</a>') . '</p>';
            }
        }
    }
}