/**
 * Checks if current page is main product listing
 *
 * @return boolean
 */
function is_ic_product_listing()
{
    $listing_id = get_product_listing_id();
    if (is_post_type_archive(product_post_type_array()) || is_home_archive() || is_ic_product_listing_enabled() && is_page($listing_id)) {
        return true;
    }
    return false;
}
예제 #2
0
function content_product_adder()
{
    if (is_archive() || is_search() || is_home_archive()) {
        do_action('before_product_archive');
        content_product_adder_archive();
    } else {
        content_product_adder_single();
    }
}
예제 #3
0
/**
 * Checks if current page is main product listing
 *
 * @return boolean
 */
function is_ic_product_listing($query = null)
{
    if (empty($query)) {
        if (is_post_type_archive(product_post_type_array()) || is_home_archive() || is_custom_product_listing_page()) {
            return true;
        }
    } else {
        if ($query->is_post_type_archive(product_post_type_array()) || is_home_archive($query)) {
            return true;
        }
    }
    return false;
}
예제 #4
0
/**
 * Adds paginaion to the product listings
 *
 * @global object $wp_query
 * @return string
 */
function product_archive_pagination()
{
    if (!is_home_archive() && is_singular() || is_ic_product_listing() && is_ic_only_main_cats()) {
        return;
    }
    global $paged, $wp_query;
    if ($wp_query->max_num_pages <= 1) {
        return;
    }
    $paged = get_query_var('paged') ? absint(get_query_var('paged')) : 1;
    $max = intval($wp_query->max_num_pages);
    if ($paged >= 1) {
        $links[] = $paged;
    }
    if ($paged >= 3) {
        $links[] = $paged - 1;
        $links[] = $paged - 2;
    }
    if ($paged + 2 <= $max) {
        $links[] = $paged + 2;
        $links[] = $paged + 1;
    }
    $names = get_archive_names();
    echo '<div id="product_archive_nav" class="product-archive-nav ' . design_schemes('box', 0) . '"><ul>' . "\n";
    if (get_previous_posts_link($names['previous_products'])) {
        printf('<li>%s</li> ' . "\n", get_previous_posts_link($names['previous_products']));
    }
    if (!in_array(1, $links)) {
        $class = 1 == $paged ? ' class="active"' : '';
        printf('<li%s><a href="%s">%s</a></li> ' . "\n", $class, esc_url(get_pagenum_link(1)), '1');
        if (!in_array(2, $links)) {
            echo '<li>…</li>';
        }
    }
    sort($links);
    foreach ((array) $links as $link) {
        $class = $paged == $link ? ' class="active"' : '';
        printf('<li%s><a href="%s">%s</a></li> ' . "\n", $class, esc_url(get_pagenum_link($link)), $link);
    }
    if (!in_array($max, $links)) {
        if (!in_array($max - 1, $links)) {
            echo '<li>…</li>' . "\n";
        }
        $class = $paged == $max ? ' class="active"' : '';
        printf('<li%s><a href="%s">%s</a></li> ' . "\n", $class, esc_url(get_pagenum_link($max)), $max);
    }
    if (get_next_posts_link($names['next_products'])) {
        printf('<li>%s</li> ' . "\n", get_next_posts_link($names['next_products']));
    }
    echo '</ul></div>' . "\n";
    wp_reset_postdata();
}
예제 #5
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);
    }
}
예제 #6
0
function get_quasi_post_type($post_type = null)
{
    if (empty($post_type) && is_home_archive()) {
        $post_type = 'al_product';
    } else {
        if (empty($post_type)) {
            $post_type = get_post_type();
        }
    }
    $quasi_post_type = substr($post_type, 0, 10);
    return $quasi_post_type;
}
/**
 * Sets product limit on product listing pages
 * @param object $query
 */
function set_products_limit($query)
{
    $archive_multiple_settings = get_multiple_settings();
    if (!is_admin() && (is_post_type_archive('al_product') || is_tax('al_product-cat') || is_home_archive($query)) && $query->is_main_query()) {
        $query->set('posts_per_page', $archive_multiple_settings['archive_products_limit']);
    }
}
예제 #8
0
파일: shortcodes.php 프로젝트: RA2WP/RA2WP
/**
 * Shows products on product listing for custom templates usage
 *
 * @return type
 */
function ic_product_listing_products()
{
    ob_start();
    global $post;
    $multiple_settings = get_multiple_settings();
    $archive_template = get_product_listing_template();
    if (is_home_archive()) {
        $args = array('post_type' => 'al_product', 'posts_per_page' => $multiple_settings['archive_products_limit']);
        query_posts($args);
        $is_home = 1;
    }
    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);
        }
        if (isset($is_home)) {
            wp_reset_query();
        }
        $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_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();
        }
    }
    return ob_get_clean();
}
					<?php 
            }
        } else {
            $show_categories = do_shortcode('[show_categories parent=' . get_queried_object_id() . ']');
            if (!empty($show_categories)) {
                echo $show_categories;
                if ($archive_template != 'list') {
                    echo '<hr>';
                }
            }
        }
    }
}
do_action('before_product_list', $archive_template, $multiple_settings);
$product_list = '<div class="product-list responsive ' . product_list_class() . '">';
if (is_home_archive()) {
    $args = array('post_type' => 'al_product');
    query_posts($args);
    $is_home = 1;
}
while (have_posts()) {
    the_post();
    $product_list .= get_catalog_template($archive_template, $post);
}
if (isset($is_home)) {
    wp_reset_query();
}
$product_list .= '</div>';
$product_list = apply_filters('product_list_ready', $product_list, $archive_template);
echo $product_list;
?>
예제 #10
0
						<?php 
                }
            } else {
                $show_categories = do_shortcode('[show_categories parent=' . get_queried_object_id() . ' shortcode_query=no]');
                if (!empty($show_categories)) {
                    do_action('before_category_subcategories');
                    echo $show_categories;
                    if ($archive_template != 'list' && !is_ic_only_main_cats()) {
                        echo '<hr>';
                    }
                }
            }
        }
    }
}
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);
    $is_home = 1;
}
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()) {
/**
 * 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>';
            }
        }
    }
}