cart; foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item){ if($cart_item['product_id'] == $_POST['product_id'] ){ // Remove product in the cart using cart_item_key. $cart->remove_cart_item($cart_item_key); woocommerce_mini_cart(); exit(); } } die(); } function almaira_shop_product_count_update(){ global $woocommerce; ?> cart->cart_contents_count); ?> 'OR', array( // Simple products type 'key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric' ), array( // Variable products type 'key' => '_min_variation_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric' ) ); $tax_query = array(); $tax_query [] = array( 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $term_id ) ), ); if($radio=='low-to-high'){ $args = array( 'post_type' => 'product', 'posts_per_page' => $posts_per_page, 'tax_query' => $tax_query, 'orderby' => 'meta_value_num', 'meta_key' => '_price', 'order' => 'ASC', 'paged' => $paged, ); } elseif($radio=='high-to-low'){ $args = array( 'post_type' => 'product', 'posts_per_page' => $posts_per_page, 'tax_query' => $tax_query, 'orderby' => 'meta_value_num', 'meta_key' => '_price', 'order' => 'DESC', 'paged' => $paged, ); }elseif($radio=='onsale'){ $args = array( 'post_type' => 'product', 'posts_per_page' => $posts_per_page, 'tax_query' => $tax_query, 'meta_query'=> $meta_query, 'paged' => $paged, ); }elseif($radio=='featured'){ $args = array( 'post_type' => 'product', 'posts_per_page' => $posts_per_page, 'tax_query' => $tax_query, 'post__in' => wc_get_featured_product_ids(), 'paged' => $paged, ); }else{ $args = array( 'post_type' => 'product', 'posts_per_page' => $posts_per_page, 'tax_query' => $tax_query, 'paged' => $paged, ); } $product = new WP_Query($args); if ( $product->have_posts()){ while ( $product->have_posts() ) : $product->the_post(); wc_get_template_part( 'content', 'product' ); endwhile; if($posts_per_page < $product->found_posts){ echo'
'; } }else{ echo __( 'No products found','almaira-shop' ); } exit; wp_reset_postdata(); } /***************************/ //category product section product ajax filter /***************************/ add_action('wp_ajax_almaira_shop_product_section_filter_product_ajax', 'almaira_shop_product_section_filter_product_ajax'); add_action('wp_ajax_nopriv_almaira_shop_product_section_filter_product_ajax', 'almaira_shop_product_section_filter_product_ajax'); function almaira_shop_product_section_filter_product_ajax(){ if( taxonomy_exists( 'product_cat' ) ){ $perpage = get_theme_mod('almaira_shop_cate_prd_shw',8); if ( empty($_POST["paged"]) ){ $paged = ( get_query_var($_POST["paged"] ) ) ? get_query_var( $_POST["paged"] ) : 1; }else{ $paged = $_POST["paged"]; } $category_product = array(); $category_product['slug'] = $_POST['cat_slug']; // product filter $args = array( 'posts_per_page' => $perpage, 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $_POST['cat_slug'], ) ), 'post_type' => 'product', 'orderby' => 'date', 'paged' => $paged, ); echo $cate_product .= almaira_shop_category_product_loop($category_product,$args); exit; } } /** * Live autocomplete search feature. * * @since 1.0.0 */ function search_site(){ $results = new WP_Query( array( 'post_type' => 'product', 'post_status' => 'publish', 'nopaging' => true, 'posts_per_page'=> 100, 's' => $_POST['match'], ) ); $items = array(); if ( !empty( $results->posts ) ) { foreach ( $results->posts as $result ) { $items[] = $result->post_title; } } wp_send_json_success( $items ); } add_action( 'wp_ajax_search_site', 'search_site' ); add_action( 'wp_ajax_nopriv_search_site', 'search_site' );