public static function shortcode($atts = array()) { $a = shortcode_atts(array('widget_type' => 'filter', 'attribute' => '', 'type' => 'checkbox', 'operator' => 'OR', 'title' => '', 'product_cat' => '', 'cat_propagation' => '', 'height' => 'auto', 'scroll_theme' => 'dark'), $atts); if (!$a['attribute'] || !$a['type']) { return false; } $BeRocket_AAPF_Widget = new BeRocket_AAPF_Widget(); $BeRocket_AAPF_Widget->widget(array(), $a); }
public static function get_price_range($wp_query_product_cat, $woocommerce_hide_out_of_stock_items) { $price_range = array(); $products = BeRocket_AAPF_Widget::get_filter_products($wp_query_product_cat, $woocommerce_hide_out_of_stock_items, false); foreach ($products as $ID) { $meta_values = get_post_meta($ID, '_price'); if ($meta_values[0] or $woocommerce_hide_out_of_stock_items != 'yes') { $price_range[] = $meta_values[0]; } } if (@count($price_range) < 2) { $price_range = false; } return apply_filters('berocket_aapf_get_price_range', $price_range); }
/** * Widget ajax listener */ public static function listener() { global $wp_query, $wp_rewrite; $br_options = apply_filters('berocket_aapf_listener_br_options', get_option('br_filters_options')); add_filter('post_class', array(__CLASS__, 'add_product_class')); add_filter('woocommerce_pagination_args', array(__CLASS__, 'pagination_args')); $args = apply_filters('berocket_aapf_listener_wp_query_args', array()); if (!isset($args['post__in'])) { $args['post__in'] = array(); } $woocommerce_hide_out_of_stock_items = BeRocket_AAPF_Widget::woocommerce_hide_out_of_stock_items(); if ($woocommerce_hide_out_of_stock_items == 'yes') { $args['post__in'] = BeRocket_AAPF::remove_out_of_stock($args['post__in']); } $args['post__in'] = BeRocket_AAPF::remove_hidden($args['post__in']); $args['post__in'] = BeRocket_AAPF::limits_filter($args['post__in']); $args['post__in'] = BeRocket_AAPF::price_filter($args['post__in']); $args['post_status'] = 'publish'; $args['post_type'] = 'product'; $args['post__in'] = BeRocket_AAPF::price_filter($args['post__in']); $default_posts_per_page = get_option('posts_per_page'); $args['posts_per_page'] = apply_filters('loop_shop_per_page', $default_posts_per_page); unset($default_posts_per_page); $wp_query = new WP_Query($args); // here we get max products to know if current page is not too big if ($wp_rewrite->using_permalinks() and preg_match("~/page/([0-9]+)~", $_POST['location'], $mathces) or preg_match("~paged?=([0-9]+)~", $_POST['location'], $mathces)) { $args['paged'] = min($mathces[1], $wp_query->max_num_pages); $wp_query = new WP_Query($args); } unset($args); if (@(!$br_options['ajax_request_load'])) { ob_start(); if ($wp_query->have_posts()) { do_action('woocommerce_before_shop_loop'); woocommerce_product_loop_start(); woocommerce_product_subcategories(); while (have_posts()) { the_post(); wc_get_template_part('content', 'product'); } woocommerce_product_loop_end(); do_action('woocommerce_after_shop_loop'); wp_reset_postdata(); $_RESPONSE['products'] = ob_get_contents(); } else { echo apply_filters('berocket_aapf_listener_no_products_message', "<div class='no-products" . ($br_options['no_products_class'] ? ' ' . $br_options['no_products_class'] : '') . "'>" . $br_options['no_products_message'] . "</div>"); $_RESPONSE['no_products'] = ob_get_contents(); } ob_end_clean(); } echo json_encode($_RESPONSE); die; }