Dynamic Product Carousel
-
Hello, i’m using woocommerce and i have an issue:
Our client wants a Carousel which shows filtered product results. The filters are attributes and price.
What he wants is
1 – to show ALL the results (no paginated) in the carousel/slider
2 – Show all the paginated results of the filter in a pagination (or infinite scroll) grid.Both in the same page.
What i’ve done >
In the Archive-product.php:
<?php if ( have_posts() ) : ?> <?php do_action( 'woocommerce_archive_description' ); ?> <?php if (is_product_category ('koi-2')): ?> <div class="carru"> <section class="regular slider"> <?php obtener_kois(); ?> </section> </div> <hr> <?php endif;?> <?php woocommerce_product_loop_start(); ?> <?php woocommerce_product_subcategories(); ?> <?php while ( have_posts() ) : the_post(); ?> <!-- Product Item --> <?php wc_get_template( 'content-product.php', array('_delay' => $_delay, 'wrapper' => 'li') ); ?> <!-- End Product Item --> <?php $_delay+=200; ?> <?php endwhile;?> <?php woocommerce_product_loop_end(); ?> <div class="row filters-container-down"> <!-- Pagination --> <?php do_action( 'woocommerce_after_shop_loop' );?> <!-- End Pagination -->Then, in functions.php:
function obtener_kois($min_price,$max_price,$atrib1,$atrib2) { $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => -1, 'product_cat' => 'category-product-slug', 'meta_query' => array( array( 'key' => '_price', 'value' => array($min_price, $max_price), 'compare' => 'BETWEEN', 'type' => 'NUMERIC' ) ), 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'pa_' . 'attribute-1', 'terms' => explode( ',', $atrib1 ), 'field' => 'term_id', 'operator' => 'IN' ), array( 'taxonomy' => 'pa_' . 'attribute-2', 'terms' => explode( ',', $atrib2 ), 'field' => 'term_id', 'operator' => 'IN' ), ) );I could make it work filtering by price and one of the attributes, but not for both attributes and price.
Do you have any idea where the problem is?
Thanks in advance!!
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
The topic ‘Dynamic Product Carousel’ is closed to new replies.