function shortcode_onsale_product_carousel($atts, $content = null) { extract(shortcode_atts(array('title' => 'On Sale', 'counts' => '16', 'order' => 'DESC', 'orderby' => 'date', 'auto' => 'false', 'speed' => '800', 'pause' => '5000', 'move_slides' => '4'), $atts)); global $woocommerce; $id = twoot_get_frontend_func('rand_num', 5); // Get products on sale $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $meta_query = $woocommerce->query->get_meta_query(); $query_args = array('posts_per_page' => $counts, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'orderby' => $orderby, 'order' => $order, 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale); $products = new WP_Query($query_args); if ($products->have_posts()) { $html = '<div class="the-carousel-list the-product-list">'; $html .= '<h5 class="carousel-title">' . $title . '</h5>'; $html .= '<ul id="post-carousel-' . $id . '" class="products clearfix">'; while ($products->have_posts()) { $products->the_post(); $html .= twoot_generator('load_template', 'loop-product-carousel'); } wp_reset_query(); $html .= '</ul>'; $html .= '</div>'; $html .= twoot_generator('carousel_script', $id, $auto, $speed, $pause, $move_slides, $tag = 'd'); } else { $html = '<div class="the-not-posts">' . esc_attr__('Hi, please check the type option, the current type is not match!', 'Twoot_Toolkit') . '</div>'; } return $html; }
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { global $wp_query, $woocommerce; $cache = wp_cache_get('widget_onsale', 'widget'); if (!is_array($cache)) { $cache = array(); } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('On Sale', 'woocommerce') : $instance['title'], $instance, $this->id_base); if (!($number = (int) $instance['number'])) { $number = 10; } else { if ($number < 1) { $number = 1; } else { if ($number > 15) { $number = 15; } } } // Get products on sale $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $meta_query = $woocommerce->query->get_meta_query(); $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'orderby' => 'date', 'order' => 'ASC', 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale); $r = new WP_Query($query_args); if ($r->have_posts()) { echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo '<ul class="product_list_widget">'; while ($r->have_posts()) { $r->the_post(); global $product; echo '<li> <a href="' . get_permalink() . '"> ' . (has_post_thumbnail() ? get_the_post_thumbnail($r->post->ID, 'shop_thumbnail') : woocommerce_placeholder_img('shop_thumbnail')) . ' ' . get_the_title() . ' </a> ' . $product->get_price_html() . ' </li>'; } echo '</ul>'; echo $after_widget; } wp_reset_postdata(); $content = ob_get_clean(); if (isset($args['widget_id'])) { $cache[$args['widget_id']] = $content; } echo $content; wp_cache_set('widget_onsale', $cache, 'widget'); }
function ux_sale_products($atts, $content = null) { global $woocommerce; $sliderrandomid = rand(); extract(shortcode_atts(array("title" => '', 'products' => '8', 'orderby' => 'date', 'order' => 'ASC', 'columns' => '4', 'infinitive' => 'false'), $atts)); ob_start(); ?> <?php /** * Check if WooCommerce is active **/ if (function_exists('wc_print_notices')) { ?> <?php if ($title) { ?> <div class="row"> <div class="large-12 columns"> <h3 class="section-title"><span><?php echo $title; ?> </span></h3> </div> </div><!-- end .title --> <?php } ?> <div class="row column-slider"> <div id="slider_<?php echo $sliderrandomid; ?> " class="iosSlider" style="overflow:hidden;height:250px;min-height:250px;"> <ul class="slider large-block-grid-<?php echo $columns; ?> small-block-grid-2"> <?php $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $meta_query = $woocommerce->query->get_meta_query(); $query_args = array('posts_per_page' => $products, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'orderby' => $orderby, 'order' => $order, 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale); $r = new WP_Query($query_args); if ($r->have_posts()) { ?> <?php while ($r->have_posts()) { $r->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } // end of the loop. ?> <?php } wp_reset_query(); ?> </ul> <!-- .slider --> <div class="sliderControlls"> <div class="sliderNav small hide-for-small"> <a href="javascript:void(0)" class="nextSlide disabled prev_<?php echo $sliderrandomid; ?> "><span class="icon-angle-left"></span></a> <a href="javascript:void(0)" class="prevSlide next_<?php echo $sliderrandomid; ?> "><span class="icon-angle-right"></span></a> </div> </div><!-- .sliderControlls --> </div> <!-- .iOsslider --> </div><!-- .row .column-slider --> <?php slider_script($sliderrandomid, $columns, $infinitive); ?> <?php } ?> <?php $content = ob_get_contents(); ob_end_clean(); return $content; }
function shortcode_sale_products_slider($atts, $content = null) { global $woocommerce; $sliderrandomid = rand(); extract(shortcode_atts(array('title' => '', 'per_page' => '12', 'columns' => '4', 'layout' => 'listing', 'orderby' => 'date', 'order' => 'desc'), $atts)); ob_start(); ?> <?php /** * Check if WooCommerce is active **/ if (class_exists('WooCommerce')) { ?> <div class="woocommerce shortcode_products_slider"> <div id="products-carousel-<?php echo $sliderrandomid; ?> " class="owl-carousel related products"> <?php // Get products on sale $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $meta_query = $woocommerce->query->get_meta_query(); $args = array('posts_per_page' => $per_page, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'orderby' => $orderby, 'order' => $order, 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale); $products = new WP_Query($args); if ($products->have_posts()) { ?> <?php while ($products->have_posts()) { $products->the_post(); ?> <ul><?php wc_get_template_part('content', 'product'); ?> </ul> <?php } // end of the loop. ?> <?php } ?> </div> </div> <?php } ?> <script> jQuery(document).ready(function($) { "use strict"; $("#products-carousel-<?php echo $sliderrandomid; ?> ").owlCarousel({ items:<?php echo $columns; ?> , itemsDesktop : [1200,<?php echo $columns; ?> ], itemsDesktopSmall : [1000,3], itemsTablet: false, itemsMobile : [600,2], lazyLoad : true }); }); </script> <?php wp_reset_query(); $content = ob_get_contents(); ob_end_clean(); return $content; }
function TS_VCSC_WooCommerce_Grid_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-visual-composer-extend-front'); } } else { wp_enqueue_script('ts-extend-hammer'); wp_enqueue_script('ts-extend-nacho'); wp_enqueue_style('ts-extend-nacho'); wp_enqueue_style('ts-extend-dropdown'); wp_enqueue_script('ts-extend-dropdown'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('dashicons'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-extend-buttons'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-extend-isotope'); wp_enqueue_script('ts-visual-composer-extend-front'); } add_action('wp_footer', array($this, 'TS_VCSC_WooCommerce_Grid_Function_Isotope'), 9999); } extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'show_image' => 'true', 'show_link' => 'true', 'link_page' => 'false', 'link_target' => '_parent', 'show_rating' => 'true', 'show_stock' => 'true', 'show_price' => 'true', 'show_cart' => 'true', 'show_info' => 'true', 'show_content' => 'excerpt', 'cutoff_characters' => 400, 'lightbox_group_name' => 'nachogroup', 'lightbox_size' => 'full', 'lightbox_effect' => 'random', 'lightbox_speed' => 5000, 'lightbox_social' => 'true', 'lightbox_backlight_choice' => 'predefined', 'lightbox_backlight_color' => '#0084E2', 'lightbox_backlight_custom' => '#000000', 'image_position' => 'ts-imagefloat-center', 'hover_type' => 'ts-imagehover-style1', 'hover_active' => 'false', 'overlay_trigger' => 'ts-trigger-hover', 'rating_maximum' => 5, 'rating_value' => 0, 'rating_dynamic' => '', 'rating_quarter' => 'true', 'rating_size' => 16, 'rating_auto' => 'false', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'false', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'post_type' => 'product', 'date_format' => 'F j, Y', 'time_format' => 'l, g:i A', 'filter_menu' => 'true', 'layout_menu' => 'true', 'sort_menu' => 'false', 'directions_menu' => 'false', 'filter_by' => 'product_cat', 'layout' => 'masonry', 'column_width' => 285, 'layout_break' => 600, 'show_periods' => 'false', 'sort_by' => 'postName', 'sort_order' => 'asc', 'posts_limit' => 25, 'posts_lazy' => 'false', 'posts_ajax' => 10, 'posts_load' => 'Show More', 'posts_trigger' => 'click', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $postsgrid_random = mt_rand(999999, 9999999); $opening = $closing = $controls = $products = ''; $posts_limit = $products_total; if (!empty($el_id)) { $posts_container_id = $el_id; } else { $posts_container_id = 'ts-vcsc-woocommerce-grid-' . $postsgrid_random; } // Backlight Color if ($lightbox_backlight_choice == "predefined") { $lightbox_backlight_selection = $lightbox_backlight_color; } else { $lightbox_backlight_selection = $lightbox_backlight_custom; } // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $product_style = ''; $frontend_edit = 'true'; $description_style = 'display: none; padding: 15px;'; } else { $product_style = ''; $frontend_edit = 'false'; $description_style = 'display: none; padding: 15px;'; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } $menu_tax = 'product_cat'; $limit_tax = 'product_cat'; // Start WordPress Query $loop = new WP_Query($args); // Language Settings: Isotope Posts $TS_VCSC_Isotope_Posts_Language = get_option('ts_vcsc_extend_settings_translationsIsotopePosts', ''); if ($TS_VCSC_Isotope_Posts_Language == false || empty($TS_VCSC_Isotope_Posts_Language)) { $TS_VCSC_Isotope_Posts_Language = $VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_Isotope_Posts_Language_Defaults; } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Grid_Basic', $atts); } else { $css_class = ''; } if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == 'false') { $isotope_posts_list_class = 'ts-posts-timeline-view'; } else { $isotope_posts_list_class = 'ts-posts-timeline-edit'; } if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == 'true') { echo '<div id="ts-isotope-posts-grid-frontend-' . $postsgrid_random . '" class="ts-isotope-posts-grid-frontend" style="border: 1px solid #ededed; padding: 10px;">'; echo '<div style="font-weight: bold;">"Basic Products Isotope Grid"</div>'; echo '<div style="margin-bottom: 20px;">The element has been disabled in order to ensure compatiblity with the Visual Composer Front-End Editor.</div>'; echo '<div>' . __("Number of Products", "ts_visual_composer_extend") . ': ' . $posts_limit . '</div>'; $front_edit_reverse = array("excerpt" => __('Excerpt', "ts_visual_composer_extend"), "cutcharacters" => __('Character Limited Content', "ts_visual_composer_extend"), "complete" => __('Full Content', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $show_content) { echo '<div>' . __("Content Length", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("masonry" => __('Centered Masonry', "ts_visual_composer_extend"), "fitRows" => __('Fit Rows', "ts_visual_composer_extend"), "straightDown" => __('Straight Down', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $layout) { echo '<div>' . __("Content", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("postName" => __('Product Name', "ts_visual_composer_extend"), "postPrice" => __('Product Price', "ts_visual_composer_extend"), "postRating" => __('Product Rating', "ts_visual_composer_extend"), "postDate" => __('Product Date', "ts_visual_composer_extend"), "postModified" => __('Product Modified', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $sort_by) { echo '<div>' . __("Sort Criterion", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("asc" => __('Bottom to Top', "ts_visual_composer_extend"), "desc" => __('Top to Bottom', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $sort_order) { echo '<div>' . __("Initial Order", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } echo '<div>' . __("Show Filter Button", "ts_visual_composer_extend") . ': ' . $filter_menu . '</div>'; echo '<div>' . __("Show Layout Button", "ts_visual_composer_extend") . ': ' . $layout_menu . '</div>'; echo '<div>' . __("Show Sort Criterion Button", "ts_visual_composer_extend") . ': ' . $sort_menu . '</div>'; echo '<div>' . __("Show Directions Buttons", "ts_visual_composer_extend") . ': ' . $directions_menu . '</div>'; echo '</div>'; } else { $opening .= '<div id="' . $posts_container_id . '" class="ts-isotope-posts-grid-parent ' . ($layout == 'spineTimeline' ? 'ts-timeline ' : 'ts-postsgrid ') . 'ts-timeline-' . $sort_order . ' ts-posts-timeline ' . $isotope_posts_list_class . ' ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';" data-lazy="' . $posts_lazy . '" data-count="' . $posts_limit . '" data-ajax="' . $posts_ajax . '" data-trigger="' . $posts_trigger . '" data-column="' . $column_width . '" data-layout="' . $layout . '" data-sort="' . $sort_by . '" data-order="' . $sort_order . '" data-break="' . $layout_break . '" data-type="' . $post_type . '">'; // Create Individual Post Output $postCounter = 0; $postCategories = array(); $categoriesCount = 0; if (post_type_exists($post_type) && $loop->have_posts()) { $products .= '<div class="ts-timeline-content">'; $products .= '<ul id="ts-isotope-posts-grid-' . $postsgrid_random . '" class="ts-isotope-posts-grid ts-timeline-list" data-layout="' . $layout . '" data-key="' . $postsgrid_random . '">'; while ($loop->have_posts()) { $loop->the_post(); $postCounter++; $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } if (has_post_thumbnail($loop->post->ID)) { $featured = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $featured = $featured[0]; $thumbnail = $thumbnail[0]; } else { $featured = woocommerce_placeholder_img_src(); $thumbnail = $featured; } $title = get_the_title(); // Create Output if ($postCounter < $posts_limit + 1) { $postAttributes = 'data-visible="false" data-price="' . TS_VCSC_CleanNumberData($product->price) . '" data-rating="' . TS_VCSC_CleanNumberData($rating) . '" data-full="' . get_post_time($date_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"'; if ($exclude_outofstock == "true" && $stock == "true" || $exclude_outofstock == "false") { $product_categories = ''; if ($filter_menu == 'true' && taxonomy_exists($menu_tax)) { foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) { $product_categories .= $term->slug . ' '; $category_check = 0; foreach ($postCategories as $index => $array) { if ($postCategories[$index]['slug'] == $term->slug) { $category_check++; } } if ($category_check == 0) { $categoriesCount++; $categories_array = array('slug' => $term->slug, 'name' => $term->name); $postCategories[] = $categories_array; } } } $product_categories .= 'rating-' . TS_VCSC_CleanNumberData($rating) . ' '; $products .= '<li class="ts-timeline-list-item ts-timeline-date-true ts-isotope-posts-list-item ' . $product_categories . '" ' . $postAttributes . ' style="margin: 10px;">'; $products .= '<div class="ts-woocommerce-product-slide" style="' . $product_style . '" data-hash="' . $product_id . '">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '" class="ts-image-hover-frame ' . $image_position . ' ts-trigger-hover-adjust" style="width: 100%;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-counter" class="ts-fluid-wrapper " style="width: 100%; height: auto;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-mask" class="ts-imagehover ' . $hover_type . ' ts-trigger-hover" data-trigger="ts-trigger-hover" data-closer="" style="width: 100%; height: auto;">'; // Product Thumbnail $products .= '<div class="ts-woocommerce-product-preview">'; $products .= '<img class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $products .= '</div>'; // Sale Ribbon if ($onsale == "true") { $products .= '<div class="ts-woocommerce-product-ribbon"></div>'; $products .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } $products .= '<div class="ts-woocommerce-product-main">'; $products .= '<div class="mask" style="width: 100%; display: block;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-maskcontent" class="maskcontent" style="margin: 0; padding: 0;">'; // Product Thubmnail if ($show_image == "true") { if ($link_page == "false") { $products .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="nch-lightbox-media" data-title="' . $title . '" rel="" href="' . $featured . '" target="' . $link_target . '">'; $products .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $products .= '</a></div>'; } else { $products .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="" data-title="' . $title . '" rel="" href="' . get_permalink() . '" target="' . $link_target . '">'; $products .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $products .= '</a></div>'; } } // Product Page Link if ($show_link == "true") { $products .= '<div class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" class="ts-woocommerce-product-link" target="_blank"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a></div>'; } // Product Rating if ($show_rating == "true") { $products .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: left;">'; $products .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $products .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $products .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $products .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $products .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; } // Product Price if ($show_price == "true") { $products .= '<div class="ts-woocommerce-product-price">'; $products .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $products .= '<div class="ts-woocommerce-product-regular"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $products .= '</div>'; } $products .= '<div class="ts-woocommerce-product-line"></div>'; // Add to Cart Button (Icon) if ($show_cart == "true") { $products .= '<div class="ts-woocommerce-link-wrapper"><a class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></div>'; } // View Description Button if ($show_info == "true") { $products .= '<div id="ts-vcsc-modal-' . $product_id . '-trigger" style="" class="ts-vcsc-modal-' . $product_id . '-parent nch-holder ts-vcsc-font-icon ts-font-icons ts-shortcode ts-icon-align-center" style="">'; $products .= '<a href="#ts-vcsc-modal-' . $product_id . '" class="nch-lightbox-modal" data-title="" data-open="false" data-delay="0" data-type="html" rel="" data-effect="' . $lightbox_effect . '" data-share="0" data-duration="' . $lightbox_speed . '" data-color="' . $lightbox_backlight_selection . '">'; $products .= '<span class="">'; $products .= '<i class="ts-font-icon ts-woocommerce-product-icon ts-woocommerce-product-info ts-ecommerce-information1" style=""></i>'; $products .= '</span>'; $products .= '</a>'; $products .= '</div>'; } // Product In-Stock or Unavailable if ($show_stock == "true") { $products .= '<div class="ts-woocommerce-product-status">'; if ($stock == 'false') { $products .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></div>'; } else { if ($stock == 'true') { $products .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></div>'; } } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; // Product Title $products .= '<h2 class="ts-woocommerce-product-title">'; $products .= $title; $products .= '</h2>'; // Product Description if ($show_info == "true") { $products .= '<div id="ts-vcsc-modal-' . $product_id . '" class="ts-modal-content nch-hide-if-javascript" style="' . $description_style . '">'; $products .= '<div class="ts-modal-white-header"></div>'; $products .= '<div class="ts-modal-white-frame">'; $products .= '<div class="ts-modal-white-inner">'; $products .= '<h2 style="border-bottom: 1px solid #eeeeee; padding-bottom: 10px; line-height: 32px; font-size: 24px; text-align: left;">' . $title . '</h2>'; $products .= '<div class="ts-woocommerce-lightbox-frame" style="width: 100%; height: 32px; margin: 10px auto; padding: 0;">'; $products .= '<a style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $products .= '<a href="' . get_permalink() . '" target="_parent" style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-link"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; $products .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 0; float: right;">'; $products .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $products .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $products .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $products .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $products .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '<div class="ts-woocommerce-product-price" style="position: inherit; margin-right: 10px; float: left; width: auto; margin-top: 0;">'; $products .= '<i style="color: #000000; margin: 0 10px 0 0;" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $products .= '<div class="ts-woocommerce-product-regular"><del style="color: #7F0000;">' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 10px auto 20px auto; width: 100%;"></div>'; $products .= '<img style="width: 100%; max-width: 250px; height: auto; margin: 10px auto;" class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $products .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 20px auto 10px auto; width: 100%;"></div>'; $products .= '<div style="margin-top: 20px; text-align: justify;">'; if ($show_content == "excerpt") { $products .= get_the_excerpt(); } else { if ($show_content == "cutcharacters") { $content = apply_filters('the_content', get_the_content()); $excerpt = TS_VCSC_TruncateHTML($content, $cutoff_characters, '...', false, true); $products .= $excerpt; } else { if ($show_content == "complete") { $products .= get_the_content(); } } } $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; } $products .= '</div>'; $products .= '</li>'; } } } $products .= '</ul>'; $products .= '</div>'; if ($posts_lazy == "true") { $products .= '<div class="ts-load-more-wrap">'; $products .= '<span class="ts-timeline-load-more">' . $posts_load . '</span>'; $products .= '</div>'; } wp_reset_postdata(); } else { $products .= '<p>Nothing found. Please check back soon!</p>'; } // Create Post Controls (Filter, Sort) $controls .= '<div id="ts-isotope-posts-grid-controls-' . $postsgrid_random . '" class="ts-isotope-posts-grid-controls">'; if ($directions_menu == 'true' && $posts_lazy == 'false') { $controls .= '<div class="ts-button ts-button-flat ts-timeline-controls-desc ts-isotope-posts-controls-desc ' . ($sort_order == "desc" ? "active" : "") . '"><span class="ts-isotope-posts-controls-desc-image"></span></div>'; $controls .= '<div class="ts-button ts-button-flat ts-timeline-controls-asc ts-isotope-posts-controls-asc ' . ($sort_order == "asc" ? "active" : "") . '"><span class="ts-isotope-posts-controls-asc-image"></span></div>'; } $controls .= '<div class="ts-isotope-posts-grid-controls-menus">'; if ($filter_menu == 'true') { if ($categoriesCount > 1) { $controls .= '<div id="ts-isotope-posts-filter-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-filter-trigger" data-dropdown="#ts-isotope-posts-filter-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['WooFilterProducts'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-filter-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label style="font-weight: bold;"><input class="ts-isotope-posts-filter ts-isotope-posts-filter-all" type="checkbox" style="margin-right: 10px;" checked="checked" data-type="all" data-key="' . $postsgrid_random . '" data-filter="*">' . $TS_VCSC_Isotope_Posts_Language['SeeAll'] . '</label></li>'; $controls .= '<li class="ts-dropdown-divider"></li>'; foreach ($postCategories as $index => $array) { $controls .= '<li><label><input class="ts-isotope-posts-filter ts-isotope-posts-filter-single" type="checkbox" style="margin-right: 10px;" data-type="single" data-key="' . $postsgrid_random . '" data-filter=".' . $postCategories[$index]['slug'] . '">' . $postCategories[$index]['name'] . '</label></li>'; } $controls .= '</ul>'; $controls .= '</div>'; } } if ($layout_menu == 'true') { $controls .= '<div id="ts-isotope-posts-layout-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-layout-trigger" data-dropdown="#ts-isotope-posts-layout-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['ButtonLayout'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-layout-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="masonry" style="margin-right: 10px;" ' . ($layout == 'masonry' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['Masonry'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="fitRows" style="margin-right: 10px;" ' . ($layout == 'fitRows' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['FitRows'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="straightDown" style="margin-right: 10px;" ' . ($layout == 'straightDown' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['StraightDown'] . '</label></li>'; $controls .= '</ul>'; $controls .= '</div>'; } if ($sort_menu == 'true') { $controls .= '<div id="ts-isotope-posts-sort-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-sort-trigger" data-dropdown="#ts-isotope-posts-sort-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['ButtonSort'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-sort-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postName" style="margin-right: 10px;" ' . ($sort_by == 'postName' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooTitle'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postPrice" style="margin-right: 10px;" ' . ($sort_by == 'postPrice' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooPrice'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postRatings" style="margin-right: 10px;" ' . ($sort_by == 'postRatings' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooRating'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postDate" style="margin-right: 10px;" ' . ($sort_by == 'postDate' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooDate'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postModified" style="margin-right: 10px;" ' . ($sort_by == 'postModified' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooModified'] . '</label></li>'; $controls .= '</ul>'; $controls .= '</div>'; } $controls .= '</div>'; $controls .= '<div class="clearFixMe" style="clear:both;"></div>'; $controls .= '</div>'; $closing .= '</div>'; echo $opening; echo $controls; echo $products; echo $closing; } $myvariable = ob_get_clean(); return $myvariable; }
" data-carousel-id="hproductsale" data-carousel-md="<?php echo esc_attr($md); ?> " data-carousel-sm="<?php echo esc_attr($sm); ?> " data-carousel-xs="<?php echo esc_attr($xs); ?> " data-carousel-ss="<?php echo esc_attr($ss); ?> "> <?php global $woocommerce, $woocommerce_loop; $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale, 'post_status' => 'publish', 'orderby' => 'menu_order', 'posts_per_page' => $hp_proscount)); $woocommerce_loop['columns'] = $product_tcolumn; if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); wc_get_template_part('content', 'product'); } }
function TS_VCSC_WooCommerce_ImageGrid_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); wp_enqueue_script('ts-extend-hammer'); wp_enqueue_script('ts-extend-nacho'); wp_enqueue_style('ts-extend-nacho'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-extend-simptip'); wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-visual-composer-extend-front'); extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'post_type' => 'product', 'limit_posts' => 'true', 'limit_by' => 'category', 'limit_term' => '', 'filter_by' => 'category', 'posts_limit' => 25, 'content_images_size' => 'medium', 'filters_show' => 'true', 'filters_available' => 'Available Groups', 'filters_selected' => 'Filtered Groups', 'filters_nogroups' => 'No Groups', 'filters_toggle' => 'Toggle Filter', 'filters_toggle_style' => '', 'filters_showall' => 'Show All', 'filters_showall_style' => '', 'data_grid_machine' => 'internal', 'data_grid_invalid' => 'false', 'data_grid_target' => '_blank', 'data_grid_breaks' => '240,480,720,960', 'data_grid_width' => 250, 'data_grid_space' => 2, 'data_grid_order' => 'false', 'data_grid_always' => 'true', 'data_grid_price' => 'true', 'fullwidth' => 'false', 'breakouts' => 6, 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $grid_class = 'ts-image-link-grid-edit'; $grid_message = '<div class="ts-composer-frontedit-message">' . __('The grid is currently viewed in front-end edit mode; grid and filter features are disabled for performance and compatibility reasons.', "ts_visual_composer_extend") . '</div>'; $image_style = 'width: 20%; height: 100%; display: inline-block; margin: 0; padding: 0;'; $grid_style = 'height: 100%;'; $frontend_edit = 'true'; } else { if ($data_grid_machine == 'internal') { $grid_class = 'ts-image-link-grid'; } else { if ($data_grid_machine == 'freewall') { $grid_class = 'ts-freewall-link-grid'; } } $image_style = ''; $grid_style = ''; $grid_message = ''; $frontend_edit = 'false'; } $randomizer = mt_rand(999999, 9999999); if (!empty($el_id)) { $modal_id = $el_id; } else { $modal_id = 'ts-vcsc-product-link-grid-' . $randomizer; } $valid_images = 0; if (!empty($data_grid_breaks)) { $data_grid_breaks = str_replace(' ', '', $data_grid_breaks); $count_columns = substr_count($data_grid_breaks, ",") + 1; } else { $count_columns = 0; } $i = -1; $b = 0; $output = ''; if ($filters_toggle_style != '') { wp_enqueue_style('ts-extend-buttonsflat'); } wp_enqueue_style('ts-extend-multiselect'); wp_enqueue_script('ts-extend-multiselect'); $meta_query = ''; $menu_tax = 'product_cat'; $limit_tax = 'product_cat'; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } // Start WordPress Query $loop = new WP_Query($args); if ($data_grid_machine == 'internal') { $class_name = 'ts-image-link-grid-frame'; } else { if ($data_grid_machine == 'freewall') { wp_enqueue_script('ts-extend-freewall'); $class_name = 'ts-image-freewall-grid-frame'; } } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $el_class . ' ' . $class_name . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_ImageGrid_Basic', $atts); } else { $css_class = $class_name . ' ' . $el_class; } $fullwidth_allow = "true"; $postCounter = 0; $modal_gallery = ''; // Front-Edit Message if ($frontend_edit == "true") { $modal_gallery .= $grid_message; if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); $matched_terms = 0; $post_thumbnail = get_the_post_thumbnail(); if ($matched_terms == 0 && ($post_thumbnail != '' || $data_grid_invalid == "false")) { $postCounter++; if ($postCounter < $posts_limit + 1) { $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; if ('' != $post_thumbnail) { $grid_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $content_images_size); $modal_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $grid_image = $grid_image[0]; $modal_image = $modal_image[0]; } else { $grid_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png'); $modal_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png'); } $categories = array(); if (taxonomy_exists($menu_tax)) { foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) { array_push($categories, $term->name); } $categories = implode($categories, ','); } $valid_images++; $modal_gallery .= '<a style="' . $image_style . '" href="' . get_permalink() . '" target="_blank" title="' . get_the_title() . '">'; $modal_gallery .= '<img id="ts-image-link-picture-' . $randomizer . '-' . $i . '" class="ts-image-link-picture" src="' . $grid_image . '" rel="link-group-' . $randomizer . '" data-include="true" data-image="' . $modal_image . '" width="100%" height="auto" title="' . get_the_title() . '" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '">'; $modal_gallery .= '</a>'; $categories = array(); } } } } else { echo __("No products could be found.", "ts_visual_composer_extend"); } wp_reset_postdata(); wp_reset_query(); } else { if ($loop->have_posts()) { if ($data_grid_machine == 'freewall') { $filter_settings = 'data-gridfilter="' . $filters_show . '" data-gridavailable="' . $filters_available . '" data-gridselected="' . $filters_selected . '" data-gridnogroups="' . $filters_nogroups . '" data-gridtoggle="' . $filters_toggle . '" data-gridtogglestyle="' . $filters_toggle_style . '" data-gridshowall="' . $filters_showall . '" data-gridshowallstyle="' . $filters_showall_style . '"'; $modal_gallery .= '<div id="ts-lightbox-freewall-grid-' . $randomizer . '-container" class="ts-lightbox-freewall-grid-container" data-random="' . $randomizer . '" data-width="' . $data_grid_width . '" data-gutter="' . $data_grid_space . '" ' . $filter_settings . ' style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;">'; } while ($loop->have_posts()) { $loop->the_post(); $matched_terms = 0; $post_thumbnail = get_the_post_thumbnail(); if ($matched_terms == 0 && ($post_thumbnail != '' || $data_grid_invalid == "false")) { $postCounter++; if ($postCounter < $posts_limit + 1) { $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; if ('' != $post_thumbnail) { $grid_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $content_images_size); $modal_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $grid_image = $grid_image[0]; $modal_image = $modal_image[0]; } else { $grid_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png'); $modal_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png'); } $categories = array(); if (taxonomy_exists($menu_tax)) { if ($filters_show == "true") { foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) { array_push($categories, $term->name); } } $categories = implode($categories, ','); } $valid_images++; $costs = $product->price; $costs = is_numeric($costs) ? wc_price($costs) : $costs; $costs = strip_tags($costs); if ($data_grid_price == "true") { $price = $costs . ' / '; } else { $price = ''; } if ($data_grid_machine == 'internal') { $modal_gallery .= '<img id="ts-image-link-picture-' . $randomizer . '-' . $i . '" class="ts-image-link-picture" src="' . $grid_image . '" rel="link-group-' . $randomizer . '" data-no-lazy="1" data-price="' . $costs . '" data-include="true" data-image="' . $modal_image . '" width="100%" height="auto" title="' . $price . get_the_title() . '" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '">'; } else { if ($data_grid_machine == 'freewall') { $modal_gallery .= '<div id="ts-lightbox-freewall-item-' . $randomizer . '-' . $i . '-parent" class="ts-lightbox-freewall-item ts-lightbox-freewall-active ' . $el_class . ' nchgrid-item nchgrid-tile" data-fixSize="false" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '" data-showing="true" data-groups="' . (!empty($categories) ? str_replace('/', ',', $categories) : "") . '" style="width: ' . $data_grid_width . 'px; margin: 0; padding: 0;">'; $modal_gallery .= '<a id="ts-lightbox-freewall-item-' . $randomizer . '-' . $i . '" href="' . get_permalink() . '" target="' . $data_grid_target . '" title="' . get_the_title() . '">'; $modal_gallery .= '<img id="ts-lightbox-freewall-picture-' . $randomizer . '-' . $i . '" class="ts-lightbox-freewall-picture" src="' . $grid_image . '" width="100%" height="auto" title="' . $price . get_the_title() . '">'; $modal_gallery .= '<div class="nchgrid-caption"></div>'; $modal_gallery .= '<div class="nchgrid-caption-text ' . ($data_grid_always == 'true' ? 'nchgrid-caption-text-always' : '') . '">' . $price . get_the_title() . '</div>'; $modal_gallery .= '</a>'; $modal_gallery .= '</div>'; } } $categories = array(); } } } if ($data_grid_machine == 'freewall') { $modal_gallery .= '</div>'; } } else { echo __("No products could be found.", "ts_visual_composer_extend"); } wp_reset_postdata(); wp_reset_query(); } if ($valid_images < $count_columns) { $data_grid_string = explode(',', $data_grid_breaks); $data_grid_breaks = array(); foreach ($data_grid_string as $single_break) { $b++; if ($b <= $valid_images) { array_push($data_grid_breaks, $single_break); } else { break; } } $data_grid_breaks = implode(",", $data_grid_breaks); } else { $data_grid_breaks = $data_grid_breaks; } $output .= '<div id="' . $modal_id . '-frame" class="' . $grid_class . ' ' . $css_class . ' ' . ($fullwidth == "true" && $fullwidth_allow == "true" ? "ts-lightbox-nacho-full-frame" : "") . '" data-random="' . $randomizer . '" data-grid="' . $data_grid_breaks . '" data-margin="' . $data_grid_space . '" data-always="' . $data_grid_always . '" data-order="' . $data_grid_order . '" data-break-parents="' . $breakouts . '" data-inline="' . $frontend_edit . '" data-gridfilter="' . $filters_show . '" data-gridavailable="' . $filters_available . '" data-gridselected="' . $filters_selected . '" data-gridnogroups="' . $filters_nogroups . '" data-gridtoggle="' . $filters_toggle . '" data-gridtogglestyle="' . $filters_toggle_style . '" data-gridshowall="' . $filters_showall . '" data-gridshowallstyle="' . $filters_showall_style . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px; position: relative;">'; if ($data_grid_machine == 'internal') { $output .= '<div id="nch-lb-grid-' . $randomizer . '" class="nch-lb-grid" data-filter="nch-lb-filter-' . $randomizer . '" style="' . $grid_style . '" data-toggle="nch-lb-toggle-' . $randomizer . '" data-random="' . $randomizer . '">'; } $output .= $modal_gallery; if ($data_grid_machine == 'internal') { $output .= '</div>'; } $output .= '</div>'; echo $output; $myvariable = ob_get_clean(); return $myvariable; }
/** * List all products on sale * * @access public * @param array $atts * @return string */ public function sale_products($atts) { global $woocommerce_loop, $woocommerce; extract(shortcode_atts(array('per_page' => '12', 'columns' => '4', 'orderby' => 'title', 'order' => 'asc'), $atts)); // Get products on sale $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $meta_query = array_filter($meta_query); $args = array('posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale); ob_start(); $products = new WP_Query($args); $woocommerce_loop['columns'] = $columns; if ($products->have_posts()) { ?> <?php woocommerce_product_loop_start(); ?> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } // end of the loop. ?> <?php woocommerce_product_loop_end(); ?> <?php } wp_reset_postdata(); return '<div class="woocommerce">' . ob_get_clean() . '</div>'; }
function TS_VCSC_WooCommerce_Slider_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); wp_enqueue_script('ts-extend-hammer'); wp_enqueue_script('ts-extend-nacho'); wp_enqueue_style('ts-extend-nacho'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndWaypoints == "true") { if (wp_script_is('waypoints', $list = 'registered')) { wp_enqueue_script('waypoints'); } else { wp_enqueue_script('ts-extend-waypoints'); } } wp_enqueue_style('ts-extend-owlcarousel2'); wp_enqueue_script('ts-extend-owlcarousel2'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-visual-composer-extend-front'); extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'show_image' => 'true', 'link_page' => 'false', 'link_target' => '_parent', 'show_rating' => 'true', 'show_stock' => 'true', 'show_price' => 'true', 'show_link' => 'true', 'show_cart' => 'true', 'show_info' => 'true', 'show_content' => 'excerpt', 'cutoff_characters' => 400, 'products_slide' => 4, 'breakpoints_custom' => 'false', 'breakpoints_items' => '1,2,3,4,5,6,7,8', 'auto_height' => 'false', 'page_rtl' => 'false', 'auto_play' => 'false', 'show_bar' => 'false', 'bar_color' => '#dd3333', 'show_speed' => 5000, 'stop_hover' => 'true', 'show_navigation' => 'true', 'show_dots' => 'true', 'items_loop' => 'false', 'animation_in' => 'ts-viewport-css-flipInX', 'animation_out' => 'ts-viewport-css-slideOutDown', 'animation_mobile' => 'false', 'lightbox_group_name' => 'nachogroup', 'lightbox_size' => 'full', 'lightbox_effect' => 'random', 'lightbox_speed' => 5000, 'lightbox_social' => 'true', 'lightbox_backlight_choice' => 'predefined', 'lightbox_backlight_color' => '#0084E2', 'lightbox_backlight_custom' => '#000000', 'image_position' => 'ts-imagefloat-center', 'hover_type' => 'ts-imagehover-style1', 'hover_active' => 'false', 'overlay_trigger' => 'ts-trigger-hover', 'rating_maximum' => 5, 'rating_value' => 0, 'rating_quarter' => 'true', 'rating_dynamic' => '', 'rating_size' => 16, 'rating_auto' => 'false', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'false', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $woo_random = mt_rand(999999, 9999999); if (!empty($el_id)) { $woo_slider_id = $el_id; } else { $woo_slider_id = 'ts-vcsc-woocommerce-slider-' . $woo_random; } $output = ''; // Backlight Color if ($lightbox_backlight_choice == "predefined") { $lightbox_backlight_selection = $lightbox_backlight_color; } else { $lightbox_backlight_selection = $lightbox_backlight_custom; } // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $slider_class = 'owl-carousel2-edit'; $slider_message = '<div class="ts-composer-frontedit-message">' . __('The slider is currently viewed in front-end edit mode; slider features are disabled for performance and compatibility reasons.', "ts_visual_composer_extend") . '</div>'; $product_style = 'width: ' . 100 / $products_slide . '%; height: 100%; float: left; margin: 0; padding: 0;'; $frontend_edit = 'true'; $description_style = 'display: none; padding: 15px;'; } else { $slider_class = 'ts-owlslider-parent owl-carousel2'; $slider_message = ''; $product_style = ''; $frontend_edit = 'false'; $description_style = 'display: none; padding: 15px;'; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $frontend_edit == "true" ? $products_slide : $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } // Start WordPress Query $loop = new WP_Query($args); if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $slider_class . ' ' . $el_class . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Slider_Basic', $atts); } else { $css_class = $slider_class . ' ' . $el_class; } $output .= '<div id="' . $woo_slider_id . '-container" class="ts-woocommerce-slider-container">'; // Add Progressbar if ($auto_play == "true" && $show_bar == "true" && $frontend_edit == "false") { $output .= '<div id="ts-owlslider-progressbar-' . $woo_random . '" class="ts-owlslider-progressbar-holder" style=""><div class="ts-owlslider-progressbar" style="background: ' . $bar_color . '; height: 100%; width: 0%;"></div></div>'; } // Add Navigation Controls if ($frontend_edit == "false") { $output .= '<div id="ts-owlslider-controls-' . $woo_random . '" class="ts-owlslider-controls" style="' . ($auto_play == "true" || $show_navigation == "true" ? "display: block;" : "display: none;") . '">'; $output .= '<div id="ts-owlslider-controls-next-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>'; $output .= '<div id="ts-owlslider-controls-prev-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>'; if ($auto_play == "true") { $output .= '<div id="ts-owlslider-controls-play-' . $woo_random . '" class="ts-owlslider-controls-play active"><span class="ts-ecommerce-pause"></span></div>'; } $output .= '</div>'; } // Front-Edit Message if ($frontend_edit == "true") { $output .= $slider_message; } // Add Slider $output .= '<div id="' . $woo_slider_id . '" class="' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;" data-id="' . $woo_random . '" data-items="' . $products_slide . '" data-breakpointscustom="' . $breakpoints_custom . '" data-breakpointitems="' . $breakpoints_items . '" data-rtl="' . $page_rtl . '" data-loop="' . $items_loop . '" data-navigation="' . $show_navigation . '" data-dots="' . $show_dots . '" data-mobile="' . $animation_mobile . '" data-animationin="' . $animation_in . '" data-animationout="' . $animation_out . '" data-height="' . $auto_height . '" data-play="' . $auto_play . '" data-bar="' . $show_bar . '" data-color="' . $bar_color . '" data-speed="' . $show_speed . '" data-hover="' . $stop_hover . '">'; if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } if (has_post_thumbnail($loop->post->ID)) { $featured = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $featured = $featured[0]; $thumbnail = $thumbnail[0]; } else { $featured = woocommerce_placeholder_img_src(); $thumbnail = $featured; } $title = get_the_title(); if ($exclude_outofstock == "true" && $stock == "true" || $exclude_outofstock == "false") { $output .= '<div class="ts-woocommerce-product-slide" style="' . $product_style . '" data-hash="' . $product_id . '">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '" class="ts-image-hover-frame ' . $image_position . ' ts-trigger-hover-adjust" style="width: 100%;">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '-counter" class="ts-fluid-wrapper " style="width: 100%; height: auto;">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '-mask" class="ts-imagehover ' . $hover_type . ' ts-trigger-hover" data-trigger="ts-trigger-hover" data-closer="" style="width: 100%; height: auto;">'; // Product Thumbnail $output .= '<div class="ts-woocommerce-product-preview">'; $output .= '<img class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $output .= '</div>'; // Sale Ribbon if ($onsale == "true") { $output .= '<div class="ts-woocommerce-product-ribbon"></div>'; $output .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } $output .= '<div class="ts-woocommerce-product-main">'; $output .= '<div class="mask" style="width: 100%; display: block;">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '-maskcontent" class="maskcontent" style="margin: 0; padding: 0;">'; // Product Thubmnail if ($show_image == "true") { if ($link_page == "false") { $output .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="nch-lightbox-media no-ajaxy" data-title="' . $title . '" rel="" href="' . $featured . '" target="' . $link_target . '">'; $output .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $output .= '</a></div>'; } else { $output .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="" data-title="' . $title . '" rel="" href="' . get_permalink() . '" target="' . $link_target . '">'; $output .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $output .= '</a></div>'; } } // Product Page Link if ($show_link == "true") { $output .= '<div class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" class="ts-woocommerce-product-link" target="' . $link_target . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a></div>'; } // Product Rating if ($show_rating == "true") { $output .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: left;">'; $output .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $output .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; } // Product Price if ($show_price == "true") { $output .= '<div class="ts-woocommerce-product-price">'; $output .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $output .= '<div class="ts-woocommerce-product-regular"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $output .= '</div>'; } $output .= '<div class="ts-woocommerce-product-line"></div>'; // Add to Cart Button (Icon) if ($show_cart == "true") { $output .= '<div class="ts-woocommerce-link-wrapper"><a class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></div>'; } // View Description Button if ($show_info == "true") { $output .= '<div id="ts-vcsc-modal-' . $product_id . '-trigger" style="" class="ts-vcsc-modal-' . $product_id . '-parent nch-holder ts-vcsc-font-icon ts-font-icons ts-shortcode ts-icon-align-center" style="">'; $output .= '<a href="#ts-vcsc-modal-' . $product_id . '" class="nch-lightbox-modal" data-title="" data-open="false" data-delay="0" data-type="html" rel="" data-effect="' . $lightbox_effect . '" data-share="0" data-duration="' . $lightbox_speed . '" data-color="' . $lightbox_backlight_selection . '">'; $output .= '<span class="">'; $output .= '<i class="ts-font-icon ts-woocommerce-product-icon ts-woocommerce-product-info ts-ecommerce-information1" style=""></i>'; $output .= '</span>'; $output .= '</a>'; $output .= '</div>'; } // Product In-Stock or Unavailable if ($show_stock == "true") { $output .= '<div class="ts-woocommerce-product-status">'; if ($stock == 'false') { $output .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></div>'; } else { if ($stock == 'true') { $output .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></div>'; } } $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; // Product Title $output .= '<h2 class="ts-woocommerce-product-title">'; $output .= $title; $output .= '</h2>'; // Product Description if ($show_info == "true") { $output .= '<div id="ts-vcsc-modal-' . $product_id . '" class="ts-modal-content nch-hide-if-javascript" style="' . $description_style . '">'; $output .= '<div class="ts-modal-white-header"></div>'; $output .= '<div class="ts-modal-white-frame">'; $output .= '<div class="ts-modal-white-inner">'; $output .= '<h2 style="border-bottom: 1px solid #eeeeee; padding-bottom: 10px; line-height: 32px; font-size: 24px; text-align: left;">' . $title . '</h2>'; $output .= '<div class="ts-woocommerce-lightbox-frame" style="width: 100%; height: 32px; margin: 10px auto; padding: 0;">'; $output .= '<a style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $output .= '<a href="' . get_permalink() . '" target="_parent" style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-link"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; $output .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 0; float: right;">'; $output .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $output .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; $output .= '<div class="ts-woocommerce-product-price" style="position: inherit; margin-right: 10px; float: left; width: auto; margin-top: 0;">'; $output .= '<i style="color: #000000; margin: 0 10px 0 0;" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $output .= '<div class="ts-woocommerce-product-regular"><del style="color: #7F0000;">' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $output .= '</div>'; $output .= '</div>'; $output .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 10px auto 20px auto; width: 100%;"></div>'; $output .= '<img style="width: 100%; max-width: 250px; height: auto; margin: 10px auto;" class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $output .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 20px auto 10px auto; width: 100%;"></div>'; $output .= '<div style="margin-top: 20px; text-align: justify;">'; if ($show_content == "excerpt") { $output .= get_the_excerpt(); } else { if ($show_content == "cutcharacters") { $content = apply_filters('the_content', get_the_content()); $excerpt = TS_VCSC_TruncateHTML($content, $cutoff_characters, '...', false, true); $output .= $excerpt; } else { if ($show_content == "complete") { $output .= get_the_content(); } } } $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; } $output .= '</div>'; } } } else { echo __("No products could be found.", "ts_visual_composer_extend"); } $output .= '</div>'; $output .= '</div>'; wp_reset_postdata(); wp_reset_query(); echo $output; $myvariable = ob_get_clean(); return $myvariable; }
function sf_product_items($asset_type, $category, $carousel, $product_size, $item_count, $width) { global $woocommerce, $woocommerce_loop; $args = array(); // ARRAY ARGUMENTS if ($asset_type == "latest-products") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'product_cat' => $category, 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_count); $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = $woocommerce->query->visibility_meta_query(); } else { if ($asset_type == "featured-products") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'product_cat' => $category, 'ignore_sticky_posts' => 1, 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $item_count); } else { if ($asset_type == "top-rated") { add_filter('posts_clauses', array($woocommerce->query, 'order_by_rating_post_clauses')); $args = array('post_type' => 'product', 'post_status' => 'publish', 'product_cat' => $category, 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_count); $args['meta_query'] = $woocommerce->query->get_meta_query(); } else { if ($asset_type == "recently-viewed") { // Get recently viewed product cookies data $viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array(); $viewed_products = array_filter(array_map('absint', $viewed_products)); // If no data, quit if (empty($viewed_products)) { return '<p class="no-products">' . __("You haven't viewed any products yet.", "swiftframework") . '</p>'; } // Create query arguments array $args = array('post_type' => 'product', 'post_status' => 'publish', 'product_cat' => $category, 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_count, 'no_found_rows' => 1, 'post__in' => $viewed_products, 'orderby' => 'rand'); // Add meta_query to query args //$args['meta_query'] = array(); // Check products stock status //$args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); } else { if ($asset_type == "sale-products") { // Get products on sale $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args = array('no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'orderby' => 'date', 'order' => 'ASC', 'product_cat' => $category, 'posts_per_page' => $item_count, 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale); } else { $args = array('posts_per_page' => $item_count, 'post_status' => 'publish', 'post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'no_found_rows' => 1, 'product_cat' => $category); $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = $woocommerce->query->visibility_meta_query(); } } } } } ob_start(); // OUTPUT PRODUCTS $products = new WP_Query($args); global $sf_sidebar_config, $sf_carouselID; if ($sf_carouselID == "") { $sf_carouselID = 1; } else { $sf_carouselID++; } if (is_singular('portfolio')) { $sf_sidebar_config = "no-sidebars"; } $columns = 4; if ($sf_sidebar_config == "no-sidebars") { if ($width == "3/4") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 3); $columns = 3; } else { if ($width == "1/2") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 2); $columns = 2; } else { if ($width == "1/4") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 1); $columns = 1; } else { if ($product_size == "mini") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 6); $columns = 6; } else { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 4); } } } } } else { if ($sf_sidebar_config == "one-sidebar") { if ($width == "3/4") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 3); $columns = 3; } else { if ($width == "1/2") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 2); $columns = 2; } else { if ($width == "1/4") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 1); $columns = 1; } else { if ($product_size == "mini") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 4); } else { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 3); $columns = 3; } } } } } else { if ($width == "3/4") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 2); $columns = 2; } else { if ($width == "1/2") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 1); $columns = 1; } else { if ($width == "1/4") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 1); $columns = 1; } else { if ($product_size == "mini") { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 3); $columns = 3; } else { $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', 2); $columns = 2; } } } } } } if ($products->have_posts()) { ?> <?php if ($carousel == "yes") { ?> <div class="product-carousel" data-columns="<?php echo $columns; ?> "> <div class="carousel-overflow"> <ul class="products list-<?php echo $asset_type; ?> " id="carousel-<?php echo $sf_carouselID; ?> "> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } // end of the loop. ?> </ul> </div> <a href="#" class="prev"><i class="ss-navigateleft"></i></a><a href="#" class="next"><i class="ss-navigateright"></i></a> </div> <?php } else { ?> <ul class="products list-<?php echo $asset_type; ?> "> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } // end of the loop. ?> </ul> <?php } ?> <?php } $product_list_output = ob_get_contents(); ob_end_clean(); wp_reset_query(); wp_reset_postdata(); remove_filter('posts_clauses', array($woocommerce->query, 'order_by_rating_post_clauses')); return $product_list_output; }
$taxonomy_value = $pw_query['ex_' . $taxonomy]; $query_tax_query[] = array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $taxonomy_value, 'operator' => 'Not IN'); } } } $query_by_id_in = ''; if (isset($pw_query['in_ids'])) { $query_by_id_in = $pw_query['in_ids']; } $query_by_id_not_in = ''; if (isset($pw_query['ex_ids'])) { $query_by_id_not_in = $pw_query['ex_ids']; } break; case "on_sale_product": $query_by_id_in = woocommerce_get_product_ids_on_sale(); $query_by_id_in[] = 0; break; case "in_stock_product": $query_meta_query[] = array('key' => '_stock_status', 'value' => "instock", 'compare' => '='); break; case "out_stock_product": $query_meta_query[] = array('key' => '_stock_status', 'value' => "outofstock", 'compare' => '='); break; } $query_meta_key = ''; $query_orderby = ''; if (isset($pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'build_query_order_by'])) { $pw_query_order = $pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'build_query_order_by']; $public_orders_array = array('ID', 'date', 'author', 'title', 'modified', 'rand', 'comment_count', 'menu_order'); if (in_array($pw_query_order, $public_orders_array)) {
function TS_VCSC_WooCommerce_Ticker_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); wp_enqueue_script('ts-extend-newsticker'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-font-teammatess'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-visual-composer-extend-front'); } extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'post_type' => 'product', 'date_format' => 'F j, Y', 'time_format' => 'l, g:i A', 'limit_posts' => 'true', 'limit_by' => 'category', 'limit_term' => '', 'filter_menu' => 'true', 'layout_menu' => 'true', 'sort_menu' => 'false', 'directions_menu' => 'false', 'filter_by' => 'category', 'ticker_direction' => 'up', 'ticker_speed' => 3000, 'ticker_break' => 480, 'ticker_border_type' => '', 'ticker_border_thick' => 1, 'ticker_border_color' => '#ededed', 'ticker_border_radius' => '', 'ticker_auto' => 'false', 'ticker_hover' => 'true', 'ticker_controls' => 'true', 'ticker_symbol' => 'false', 'ticker_icon' => '', 'ticker_paint' => '#ffffff', 'ticker_title' => 'true', 'ticker_header' => 'Latest Products', 'ticker_background' => '#D10000', 'ticker_color' => '#ffffff', 'ticker_type' => 'true', 'ticker_image' => 'true', 'ticker_price' => 'true', 'ticker_cart' => 'true', 'ticker_add_item' => 'Add This Item', 'ticker_remove_item' => 'Remove This Item', 'ticker_rating' => 'true', 'ticker_stock' => 'false', 'ticker_side' => 'left', 'ticker_fixed' => 'false', 'ticker_position' => 'top', 'ticker_adjustment' => 0, 'ticker_target' => '_parent', 'posts_limit' => 25, 'rating_maximum' => 5, 'rating_size' => 20, 'rating_quarter' => 'true', 'rating_name' => 'true', 'rating_auto' => 'true', 'rating_position' => 'top', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'true', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $woo_random = mt_rand(999999, 9999999); if (!empty($el_id)) { $woo_ticker_id = $el_id; } else { $woo_ticker_id = 'ts-vcsc-woocommerce-ticker-' . $woo_random; } $output = ''; // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $frontend_edit = 'true'; $ticker_fixed = 'false'; $ticker_auto = 'false'; } else { $frontend_edit = 'false'; $ticker_fixed = $ticker_fixed; $ticker_auto = $ticker_auto; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } // Start WordPress Query $loop = new WP_Query($args); if ($ticker_fixed == "true") { $newsticker_class = 'ts-newsticker-fixed'; $newsticker_position = 'ts-newsticker-' . $ticker_position; if ($ticker_position == "top") { $newsticker_style = 'top: ' . $ticker_adjustment . 'px;'; } else { $newsticker_style = 'bottom: ' . $ticker_adjustment . 'px;'; } $margin_top = 0; $margin_bottom = 0; } else { $newsticker_class = 'ts-newsticker-standard'; $newsticker_position = ''; $newsticker_style = ''; } if ($ticker_border_type != '') { $newsticker_border = 'border: ' . $ticker_border_thick . 'px ' . $ticker_border_type . ' ' . $ticker_border_color . ';'; } else { $newsticker_border = ''; } if ($ticker_side == "left") { $newsticker_elements = 'ts-newsticker-elements-left'; } else { $newsticker_elements = 'ts-newsticker-elements-right'; } if ($ticker_title == "false") { $newsticker_header = 'left: 0;'; $newsticker_controls = 'right: 10px;'; } else { $newsticker_header = ''; $newsticker_controls = ''; } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $el_class . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Ticker_Basic', $atts); } else { $css_class = $slider_class . ' ' . $el_class; } $output .= '<div id="' . $woo_ticker_id . '" class="ts-newsticker-parent ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';">'; // Create Individual Post Output $postCounter = 0; $postMonths = array(); if ($loop->have_posts()) { $output .= '<div id="ts-newsticker-oneliner-' . $woo_random . '" class="ts-newsticker-oneliner ' . $newsticker_class . ' ' . $newsticker_position . ' ' . $ticker_border_radius . '" style="' . $newsticker_style . ' ' . $newsticker_border . '" data-ticker="ts-newsticker-ticker-' . $woo_random . '" data-controls="ts-newsticker-controls-' . $woo_random . '" data-navigation="' . $ticker_controls . '" data-break="' . $ticker_break . '" data-auto="' . $ticker_auto . '" data-speed="' . $ticker_speed . '" data-hover="' . $ticker_hover . '" data-direction="' . $ticker_direction . '" data-parent="' . $woo_ticker_id . '" data-side="' . $ticker_side . '" data-header="ts-newsticker-header-' . $woo_random . '" data-next="ts-newsticker-controls-next-' . $woo_random . '" data-prev="ts-newsticker-controls-prev-' . $woo_random . '" data-play="ts-newsticker-controls-play-' . $woo_random . '" data-stop="ts-newsticker-controls-stop-' . $woo_random . '">'; $output .= '<div class="ts-newsticker-elements-frame ' . $newsticker_elements . ' ' . $ticker_border_radius . '" style="">'; // Add Navigation Controls $output .= '<div id="ts-newsticker-controls-' . $woo_random . '" class="ts-newsticker-controls" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . ' ' . $newsticker_controls . '">'; $output .= '<div id="ts-newsticker-controls-next-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>'; $output .= '<div id="ts-newsticker-controls-prev-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>'; $output .= '<div id="ts-newsticker-controls-stop-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: block;" : "display: none;") . '"><span class="ts-ecommerce-pause"></span></div>'; $output .= '<div id="ts-newsticker-controls-play-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: none;" : "display: block;") . '"><span class="ts-ecommerce-play"></span></div>'; $output .= '</div>'; if ($ticker_side == "left" && $ticker_title == "true") { $output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; left: 0;">'; if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") { $output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>'; } $output .= '<span>' . $ticker_header . '</span>'; $output .= '</div>'; } $output .= '<ul id="ts-newsticker-ticker-' . $woo_random . '" class="newsticker ' . $ticker_border_radius . '" style="' . $newsticker_header . '">'; while ($loop->have_posts()) { $loop->the_post(); $postCounter++; if ($postCounter < $posts_limit + 1) { $postAttributes = 'data-full="' . get_post_time($date_format) . '" data-time="' . get_post_time($time_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"'; $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } // Check if Product already in Cart $cart_page_id = wc_get_page_id('cart'); $already_added = "false"; foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { if ($product_id == $cart_item['product_id']) { $already_added = "true"; $cart_link = apply_filters('woocommerce_cart_item_remove_link', sprintf('<a class="ts-newsticker-product-remove" href="%s" title="%s" rel="" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cross2"></i></a>', esc_url($woocommerce->cart->get_remove_url($cart_item_key)), $ticker_remove_item), $cart_item_key); } } if ($already_added == "false") { $cart_link = '<span class="ts-woocommerce-link-wrapper"><a class="ts-newsticker-product-purchase" href="?add-to-cart=' . $product_id . '" title="' . $ticker_add_item . '" rel="" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></span>'; } $output .= '<li ' . $postAttributes . '>'; if ($ticker_image == 'true') { if ('' != get_the_post_thumbnail()) { $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $output .= '<img class="ts-newsticker-image" src="' . $thumbnail[0] . '" style="">'; } } $output .= '<span class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" target="' . $ticker_target . '">'; $output .= get_the_title(); $output .= '</a></span>'; // Product Price if ($ticker_price == "true") { $output .= '<span class="ts-newsticker-pricetag" style="">'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $output .= '<span class="ts-newsticker-product-regular" style="float: none;"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </span><span class="ts-newsticker-product-special" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } else { $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } } else { $to = $product->price; $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } } else { $to = $product->price; $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } $output .= '</span>'; } // Sale Ribbon if ($onsale == "true") { $output .= '<i style="position: inherit" class="ts-newsticker-product-sale ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } // Product Rating if ($ticker_rating == "true") { $output .= '<span class="ts-rating-stars-frame" data-auto="false" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: none;">'; $output .= '<span class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<span class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</span>'; } $output .= '<span class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<span class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></span>'; $output .= '</span>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<span class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</span>'; } $output .= '</span>'; $output .= '</span>'; } // Add to Cart Icon if ($ticker_cart == "true") { //$output .= '<a class="ts-newsticker-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $output .= $cart_link; } // Product In-Stock or Unavailable if ($ticker_stock == "true") { $output .= '<span class="ts-woocommerce-product-status" style="margin-left: 10px;">'; if ($stock == 'false') { $output .= '<span class="ts-woocommerce-product-stock" style="position: inherit;"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></span>'; } else { if ($stock == 'true') { $output .= '<span class="ts-woocommerce-product-stock" style="position: inherit;"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></span>'; } } $output .= '</span>'; } $output .= '</li>'; } } $output .= '</ul>'; if ($ticker_side == "right" && $ticker_title == "true") { $output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; right: 0;">'; if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") { $output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>'; } $output .= '<span>' . $ticker_header . '</span>'; $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; } else { echo __("No products could be found.", "ts_visual_composer_extend"); } $output .= '</div>'; wp_reset_postdata(); wp_reset_query(); echo $output; $myvariable = ob_get_clean(); return $myvariable; }
function kad_carousel_shortcode_function($atts, $content) { extract(shortcode_atts(array('type' => '', 'id' => rand(10, 100), 'columns' => '4', 'orderby' => '', 'order' => '', 'sxlcol' => '', 'xlcol' => '', 'mcol' => '', 'scol' => '', 'xscol' => '', 'sscol' => '', 'offset' => null, 'autoplay' => 'true', 'speed' => '9000', 'scroll' => '', 'cat' => '', 'fullwidth' => 'standard', 'readmore' => false, 'ratio' => 'defualt', 'items' => '8'), $atts)); if (empty($type)) { $type = 'post'; } if (empty($orderby)) { $orderby = 'menu_order'; } if (!empty($order)) { $order = $order; } else { if ($orderby == 'menu_order') { $order = 'ASC'; } else { $order = 'DESC'; } } if (!empty($cat)) { $carousel_category = $cat; } else { $carousel_category = ''; } if (empty($scroll) || $scroll == 1) { $scroll = '1'; } else { $scroll = null; } global $pinnacle; if (isset($pinnacle['product_shop_style'])) { $product_shop_style = $pinnacle['product_shop_style']; } else { $product_shop_style = 'kad-simple-shop'; } if ($type == "portfolio") { if (isset($pinnacle['portfolio_style_default'])) { $pstyleclass = $pinnacle['portfolio_style_default']; } else { $pstyleclass = 'padded_style'; } if (isset($pinnacle['portfolio_hover_style_default'])) { $phoverstyleclass = $pinnacle['portfolio_hover_style_default']; } else { $phoverstyleclass = 'p_lightstyle'; } $shortcodeclasses[] = $pstyleclass; $shortcodeclasses[] = $phoverstyleclass; $shortcodeclasses[] = 'kt-portfolio-carousel'; if (isset($pinnacle['portfolio_viewdetails_text']) && !empty($pinnacle['portfolio_viewdetails_text'])) { $viewdetails = $pinnacle['portfolio_viewdetails_text']; } else { $viewdetails = __('View details', 'pinnacle'); } } else { $shortcodeclasses[] = ''; } if ($fullwidth == 'fullwidth') { if ($columns == '2') { $itemsize = 'tcol-sxl-3 tcol-xl-4 tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12'; $slidewidth = 700; $sxl = 4; $xl = 3; $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '1') { $itemsize = 'tcol-sxl-12 tcol-xl-12 tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12'; $slidewidth = 460; $sxl = 1; $xl = 1; $md = 1; $sm = 1; $xs = 1; $ss = 1; } else { if ($columns == '3') { $itemsize = 'tcol-sxl-25 tcol-xl-3 tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 460; $sxl = 5; $xl = 4; $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $itemsize = 'tcol-sxl-2 tcol-xl-2 tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 300; $sxl = 6; $xl = 6; $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $itemsize = 'tcol-sxl-2 tcol-xl-2 tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 300; $sxl = 6; $xl = 6; $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $itemsize = 'tcol-sxl-2 tcol-xl-25 tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 360; $sxl = 6; $xl = 5; $md = 4; $sm = 3; $xs = 2; $ss = 1; } } } } } } else { if ($columns == '2') { $itemsize = 'tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12'; $slidewidth = 600; $sxl = 2; $xl = 2; $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '1') { $itemsize = 'tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12'; $slidewidth = 400; $sxl = 1; $xl = 1; $md = 1; $sm = 1; $xs = 1; $ss = 1; } else { if ($columns == '3') { $itemsize = 'tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 400; $sxl = 3; $xl = 3; $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $itemsize = 'tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 300; $sxl = 6; $xl = 6; $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $itemsize = 'tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 300; $sxl = 5; $xl = 5; $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $itemsize = 'tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 300; $sxl = 4; $xl = 4; $md = 4; $sm = 3; $xs = 2; $ss = 1; } } } } } } if (!empty($sxlcol)) { $sxl = $sxlcol; } if (!empty($xlcol)) { $xl = $xlcol; } if (!empty($mcol)) { $md = $mcol; } if (!empty($scol)) { $sm = $scol; } if (!empty($xscol)) { $xs = $xscol; } if (!empty($sscol)) { $ss = $sscol; } ob_start(); ?> <div class="carousel_outerrim kad-animation" data-animation="fade-in" data-delay="0"> <div class="home-margin carousel_outerrim_load fredcarousel"> <div id="carouselcontainer-<?php echo esc_attr($id); ?> " class="rowtight <?php echo implode(" ", $shortcodeclasses); ?> fadein-carousel"> <div id="carousel-<?php echo esc_attr($id); ?> " class="clearfix <?php echo esc_attr($product_shop_style); ?> blog_carousel initcaroufedsel caroufedselclass products" data-carousel-container="#carouselcontainer-<?php echo esc_attr($id); ?> " data-carousel-transition="300" data-carousel-scroll="<?php echo esc_attr($scroll); ?> " data-carousel-auto="<?php echo esc_attr($autoplay); ?> " data-carousel-speed="<?php echo esc_attr($speed); ?> " data-carousel-id="<?php echo esc_attr($id); ?> " data-carousel-sxl="<?php echo esc_attr($sxl); ?> " data-carousel-xl="<?php echo esc_attr($xl); ?> " data-carousel-md="<?php echo esc_attr($md); ?> " data-carousel-sm="<?php echo esc_attr($sm); ?> " data-carousel-xs="<?php echo esc_attr($xs); ?> " data-carousel-ss="<?php echo esc_attr($ss); ?> "> <?php if ($type == "portfolio") { if (isset($pinnacle['portfolio_ratio_default'])) { $pimgratio = $pinnacle['portfolio_ratio_default']; } else { $pimgratio = "square"; } if ($pimgratio == 'portrait') { $temppimgheight = $slidewidth * 1.35; $slideheight = floor($temppimgheight); } else { if ($pimgratio == 'landscape') { $temppimgheight = $slidewidth / 1.35; $slideheight = floor($temppimgheight); } else { if ($pimgratio == 'widelandscape') { $temppimgheight = $slidewidth / 2; $slideheight = floor($temppimgheight); } else { $slideheight = $slidewidth; } } } global $kt_portfolio_loop; $kt_portfolio_loop = array('lightbox' => 'false', 'showexcerpt' => 'false', 'showtypes' => 'true', 'pstyleclass' => $pstyleclass, 'viewdetails' => $viewdetails, 'slidewidth' => $slidewidth, 'slideheight' => $slideheight); $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('orderby' => $orderby, 'order' => $order, 'offset' => $offset, 'post_type' => 'portfolio', 'portfolio-type' => $carousel_category, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <div class="<?php echo esc_attr($itemsize); ?> all p-item"> <?php do_action('kadence_portfolio_loop_start'); get_template_part('templates/content', 'loop-portfolio'); do_action('kadence_portfolio_loop_start'); ?> </div> <?php } } else { ?> <li class="error-not-found"><?php _e('Sorry, no portfolio entries found.', 'pinnacle'); ?> </li> <?php } $wp_query = null; wp_reset_query(); } else { if ($type == "post") { global $postcolumn; $postcolumn = $columns; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('orderby' => $orderby, 'order' => $order, 'offset' => $offset, 'post_type' => 'post', 'category_name' => $carousel_category, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <div class="<?php echo $itemsize; ?> b_item kad_blog_item"> <?php get_template_part('templates/content', 'post-grid-carousel'); ?> </div> <?php } } else { ?> <div class="error-not-found"><?php _e('Sorry, no post entries found.', 'pinnacle'); ?> </div> <?php } $wp_query = null; wp_reset_query(); } else { if ($type == "featured-products") { global $woocommerce_loop; if ($columns == 1) { $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'post_status' => 'publish', 'orderby' => $orderby, 'order' => $order, 'offset' => $offset, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); woocommerce_get_template_part('content', 'product'); } } $wp_query = null; wp_reset_query(); } else { if ($type == "sale-products") { if (class_exists('woocommerce')) { global $woocommerce, $woocommerce_loop; $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); } if ($columns == 1) { $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale, 'product_cat' => $carousel_category, 'post_status' => 'publish', 'offset' => $offset, 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); woocommerce_get_template_part('content', 'product'); } } $wp_query = null; wp_reset_query(); } else { if ($type == "best-products") { global $woocommerce_loop; if ($columns == 1) { $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'post_status' => 'publish', 'offset' => $offset, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); woocommerce_get_template_part('content', 'product'); } } $wp_query = null; wp_reset_query(); } else { if ($type == "cat-products") { global $woocommerce_loop; if ($columns == 1) { $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'orderby' => $orderby, 'order' => $order, 'offset' => $offset, 'product_cat' => $carousel_category, 'post_status' => 'publish', 'posts_per_page' => $items, 'meta_key' => '_visibility', 'meta_value' => 'visible')); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); woocommerce_get_template_part('content', 'product'); } } $wp_query = null; wp_reset_query(); } } } } } } ?> </div> </div> <div class="clearfix"></div> <a id="prevport-<?php echo $id; ?> " class="prev_carousel kt-icon-arrow-left" href="#"></a> <a id="nextport-<?php echo $id; ?> " class="next_carousel kt-icon-arrow-right" href="#"></a> </div> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function df_woocommerce_product_sc($atts, $content = null) { global $woocommerce, $woocommerce_loop; if (empty($atts)) { return; } extract(shortcode_atts(array("product_type" => "", "carousel" => "", "widths" => "1/1", "item_perpage" => ""), $atts)); $args = array(); // ARRAY ARGUMENTS if ($product_type == "latest-products") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_perpage); } else { if ($product_type == "featured-products") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $item_perpage); } else { if ($product_type == "top-rated") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_perpage); $args['meta_query'] = WC()->query->get_meta_query(); } else { if ($product_type == "recently-viewed") { // Get recently viewed product cookies data $viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array(); $viewed_products = array_filter(array_map('absint', $viewed_products)); // If no data, quit if (empty($viewed_products)) { return '<p class="no-products">' . __("You haven't viewed any products yet.", "dahztheme") . '</p>'; } // Create query arguments array $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_perpage, 'no_found_rows' => 1, 'post__in' => $viewed_products, 'orderby' => 'rand'); } else { if ($product_type == "sale-products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = WC()->query->visibility_meta_query(); $meta_query[] = WC()->query->stock_status_meta_query(); $meta_query = array_filter($meta_query); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_perpage, 'meta_query' => $meta_query, 'post__in' => array_merge(array(0), $product_ids_on_sale)); } else { if ($product_type == "sku-id") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_perpage, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'))); if (isset($atts['skus'])) { $skus = explode(',', $atts['skus']); $skus = array_map('trim', $skus); $args['meta_query'][] = array('key' => '_sku', 'value' => $skus, 'compare' => 'IN'); } if (isset($atts['ids'])) { $ids = explode(',', $atts['ids']); $ids = array_map('trim', $ids); $args['post__in'] = $ids; } } else { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_perpage, 'meta_key' => 'total_sales', 'orderby' => 'meta_value'); } } } } } } ob_start(); // OUTPUT PRODUCTS $products = new WP_Query($args); $single_layout = get_post_meta(get_the_ID(), 'df_metabox_layout_content', true); $number = 4; $classes = ''; if ($single_layout == 'one-col') { switch ($widths) { case '2/3': $woocommerce_loop['columns'] = 3; $number = 3; break; case '1/2': $woocommerce_loop['columns'] = 2; $number = 2; break; case '1/4': $woocommerce_loop['columns'] = 1; $number = 1; break; default: $woocommerce_loop['columns'] = 4; break; } } elseif ($single_layout == 'two-col-left' || $single_layout == 'two-col-right') { $woocommerce_loop['columns'] = 3; $number = 3; } else { switch ($widths) { case '2/3': $woocommerce_loop['columns'] = 3; $number = 3; break; case '1/2': $woocommerce_loop['columns'] = 2; $number = 2; break; case '1/4': $woocommerce_loop['columns'] = 1; $number = 1; break; default: $woocommerce_loop['columns'] = 4; break; } } $id = mt_rand(99, 9999); if ($products->have_posts()) { ?> <?php if ($carousel == "yes") { ?> <?php wp_enqueue_script('owl-carousel'); ?> <script> jQuery(function($){ var owl = $("#carousel-product-<?php echo $id; ?> "); $(document).ready(function(){ owl.owlCarousel({ items : <?php echo $number; ?> , pagination: false, itemsDesktopSmall: [979,3], itemsTablet: [768,2], itemsMobile: [481,1], afterAction : afterAction }); function afterAction (slider_count) { var slider_count = $('#carousel-product-<?php echo $id; ?> ').find('.owl-item').length; if( slider_count < 4 ){ $('.next-<?php echo $id; ?> ').addClass('disabled'); $('.prev-<?php echo $id; ?> ').addClass('disabled'); } else { $('.next-<?php echo $id; ?> ').removeClass('disabled'); $('.prev-<?php echo $id; ?> ').removeClass('disabled'); } } if( $(window).width() < 480 ){ $('.product-slider-sc li').each(function() { var _this = $(this); _this.css({'width':'auto'}); }); } else { $('.product-slider-sc li').each(function() { var _this = $(this); var parentW = $('.owl-item').width() - 30; _this.width(parentW); _this.css({'padding':'0 15px'}); }); } // Custom Navigation Events $(".next-<?php echo $id; ?> ").click(function(){ owl.trigger('owl.next'); }) $(".prev-<?php echo $id; ?> ").click(function(){ owl.trigger('owl.prev'); }) }); }); </script> <div class="woocommerce product-slider-sc woocommerce-columns-<?php echo $number; ?> "> <ul id="carousel-product-<?php echo $id; ?> " class="products df_row-fluid list-<?php echo $product_type; ?> "> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php wc_get_template_part('content', 'product'); ?> <?php } // end of the loop. ?> </ul> <div class="carouselNav control"> <a class="next prev-<?php echo $id; ?> "><i class="df-arrow-grand-left"></i></a> <a class="prev next-<?php echo $id; ?> "><i class="df-arrow-grand-right"></i></a> </div> </div> <?php } else { ?> <div class="woocommerce woocommerce-columns-<?php echo $number; ?> "> <ul class="products df_row-fluid list-<?php echo $product_type; ?> "> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php wc_get_template_part('content', 'product'); ?> <?php } // end of the loop. ?> </ul> </div> <?php } ?> <?php } $product_list_output = ob_get_contents(); ob_end_clean(); wp_reset_query(); wp_reset_postdata(); remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); return $product_list_output; }
/** * Function to apply product discounts after tax. * * @access public * @param mixed $values * @param mixed $price */ public function apply_product_discounts_after_tax($values, $price) { if (!empty($this->applied_coupons)) { foreach ($this->applied_coupons as $code) { $coupon = new WC_Coupon($code); do_action('woocommerce_product_discount_after_tax_' . $coupon->type, $coupon, $values, $price); if (!$coupon->is_valid()) { continue; } if ($coupon->type != 'fixed_product' && $coupon->type != 'percent_product') { continue; } if (!$coupon->apply_before_tax()) { $product_cats = wp_get_post_terms($values['product_id'], 'product_cat', array("fields" => "ids")); $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $this_item_is_discounted = false; // Specific products get the discount if (sizeof($coupon->product_ids) > 0) { if (in_array($values['product_id'], $coupon->product_ids) || in_array($values['variation_id'], $coupon->product_ids) || in_array($values['data']->get_parent(), $coupon->product_ids)) { $this_item_is_discounted = true; } // Category discounts } elseif (sizeof($coupon->product_categories) > 0) { if (sizeof(array_intersect($product_cats, $coupon->product_categories)) > 0) { $this_item_is_discounted = true; } } else { // No product ids - all items discounted $this_item_is_discounted = true; } // Specific product ID's excluded from the discount if (sizeof($coupon->exclude_product_ids) > 0) { if (in_array($values['product_id'], $coupon->exclude_product_ids) || in_array($values['variation_id'], $coupon->exclude_product_ids) || in_array($values['data']->get_parent(), $coupon->exclude_product_ids)) { $this_item_is_discounted = false; } } // Specific categories excluded from the discount if (sizeof($coupon->exclude_product_categories) > 0) { if (sizeof(array_intersect($product_cats, $coupon->exclude_product_categories)) > 0) { $this_item_is_discounted = false; } } // Sale Items excluded from discount if ($coupon->exclude_sale_items == 'yes') { if (in_array($values['product_id'], $product_ids_on_sale, true) || in_array($values['variation_id'], $product_ids_on_sale, true) || in_array($values['data']->get_parent(), $product_ids_on_sale, true)) { $this_item_is_discounted = false; } } // Apply filter $this_item_is_discounted = apply_filters('woocommerce_item_is_discounted', $this_item_is_discounted, $values, $before_tax = false, $coupon); // Apply the discount if ($this_item_is_discounted) { if ($coupon->type == 'fixed_product') { if ($price < $coupon->amount) { $discount_amount = $price; } else { $discount_amount = $coupon->amount; } $this->discount_total = $this->discount_total + $discount_amount * $values['quantity']; $this->increase_coupon_discount_amount($code, $discount_amount * $values['quantity']); } elseif ($coupon->type == 'percent_product') { $this->discount_total = $this->discount_total + round($price / 100 * $coupon->amount, $this->dp); $this->increase_coupon_discount_amount($code, round($price / 100 * $coupon->amount, $this->dp)); } } } } } }
function wpo_woocommerce_query($type, $post_per_page = -1, $cat = '') { global $woocommerce; $args = array('post_type' => 'product', 'posts_per_page' => $post_per_page, 'post_status' => 'publish'); switch ($type) { case 'deals': $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = $woocommerce->query->visibility_meta_query(); $args['meta_query'][] = array('key' => '_sale_price_dates_to', 'value' => '0', 'compare' => '>'); $args['post__in'] = woocommerce_get_product_ids_on_sale(); break; case 'best_selling': $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['ignore_sticky_posts'] = 1; $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = $woocommerce->query->visibility_meta_query(); break; case 'featured_product': $args['ignore_sticky_posts'] = 1; $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = array('key' => '_featured', 'value' => 'yes'); $query_args['meta_query'][] = $woocommerce->query->visibility_meta_query(); break; case 'top_rate': add_filter('posts_clauses', array($woocommerce->query, 'order_by_rating_post_clauses')); $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = $woocommerce->query->visibility_meta_query(); break; case 'recent_product': $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); break; case 'on_sale': $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = $woocommerce->query->visibility_meta_query(); $args['post__in'] = wc_get_product_ids_on_sale(); break; case 'recent_review': if ($number == -1) { $_limit = 4; } else { $_limit = $number; } global $wpdb; $query = "SELECT c.comment_post_ID FROM {$wpdb->prefix}posts p, {$wpdb->prefix}comments c WHERE p.ID = c.comment_post_ID AND c.comment_approved > 0 AND p.post_type = 'product' AND p.post_status = 'publish' AND p.comment_count > 0 ORDER BY c.comment_date ASC LIMIT 0, " . $_limit; $results = $wpdb->get_results($query, OBJECT); $_pids = array(); foreach ($results as $re) { $_pids[] = $re->comment_post_ID; } $args['meta_query'] = array(); $args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'][] = $woocommerce->query->visibility_meta_query(); $args['post__in'] = $_pids; break; } if ($cat != '') { $args['product_cat'] = $cat; } return new WP_Query($args); }
/** * List all products on sale */ function etheme_woocommerce_sale_products($atts) { global $woocommerce_loop, $woocommerce; extract(shortcode_atts(array('limit' => '12', 'columns' => '4', 'orderby' => 'title', 'order' => 'asc'), $atts)); // Get products on sale $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args = array('posts_per_page' => $limit, 'orderby' => $orderby, 'order' => $order, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale); ob_start(); $products = new WP_Query($args); $woocommerce_loop['columns'] = $columns; if ($products->have_posts()) { ?> <div id="products-grid" class="products_grid shortcode-products row rows-count<?php echo $columns; ?> "> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } // end of the loop. ?> </div> <div class="clear"></div> <script type="text/javascript">imageTooltip(jQuery('.imageTooltip'))</script> <?php } wp_reset_query(); return ob_get_clean(); }
function get_sale_products($per_page = 12, $orderby = 'title', $order = 'asc') { global $woocommerce; // Get products on sale $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = WC()->query->visibility_meta_query(); $meta_query[] = WC()->query->stock_status_meta_query(); $meta_query = array_filter($meta_query); $args = array('posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'meta_query' => $meta_query, 'post__in' => array_merge(array(0), $product_ids_on_sale)); return new WP_Query($args); }
public function add_onsale_args_query($args = array()) { $woocommerce_db_version = get_option('woocommerce_db_version', null); if (version_compare($woocommerce_db_version, '2.0', '<') && null !== $woocommerce_db_version) { $meta_query = array(); $meta_query[] = array('key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'NUMERIC'); $on_sale = get_posts(array('numberposts' => -1, 'post_type' => array('product', 'product_variation'), 'post_status' => 'publish', 'meta_query' => $meta_query, 'fields' => 'id=>parent')); $product_ids = array_keys($on_sale); $parent_ids = array_values($on_sale); // Check for scheduled sales which have not started foreach ($product_ids as $key => $id) { if (get_post_meta($id, '_sale_price_dates_from', true) > current_time('timestamp')) { unset($product_ids[$key]); } } $product_ids_on_sale = array_unique(array_merge($product_ids, $parent_ids)); $product_ids_on_sale[] = 0; } else { // Get products on sale $product_ids_on_sale = version_compare($woocommerce_db_version, '2.1', '<') ? woocommerce_get_product_ids_on_sale() : wc_get_product_ids_on_sale(); } $meta_query = array(); if (version_compare($woocommerce_db_version, '2.1', '<')) { global $woocommerce; $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); } else { $meta_query[] = WC()->query->visibility_meta_query(); $meta_query[] = WC()->query->stock_status_meta_query(); } $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; return $args; }
function kad_carousel_shortcode_function($atts, $content) { extract(shortcode_atts(array('type' => '', 'columns' => '4', 'orderby' => '', 'speed' => '9000', 'scroll' => '', 'cat' => '', 'readmore' => false, 'items' => '8'), $atts)); $carousel_rn = rand(10, 100); if (empty($type)) { $type = 'post'; } if (empty($orderby)) { $orderby = 'menu_order'; } if ($orderby == 'menu_order') { $order = 'ASC'; } else { $order = 'DESC'; } if (empty($cat)) { $cat = ''; } if (empty($scroll) || $scroll == 1) { $scroll = 'items:1,'; } else { $scroll = ''; } ob_start(); ?> <div class="carousel_outerrim kad-animation" data-animation="fade-in" data-delay="0"> <div class="home-margin fredcarousel"> <div id="carouselcontainer-<?php echo $carousel_rn; ?> " class="rowtight fadein-carousel"> <div id="carousel-<?php echo $carousel_rn; ?> " class="clearfix caroufedselclass products"> <?php if ($type == "portfolio") { if ($columns == '2') { $itemsize = 'tcol-lg-6 tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12'; $slidewidth = 560; $slideheight = 560; $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '1') { $itemsize = 'tcol-lg-12 tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12'; $slidewidth = 560; $slideheight = 560; $md = 1; $sm = 1; $xs = 1; $ss = 1; } else { if ($columns == '3') { $itemsize = 'tcol-lg-4 tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 400; $slideheight = 400; $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $itemsize = 'tcol-lg-2 tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 240; $slideheight = 240; $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $itemsize = 'tcol-lg-25 tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 240; $slideheight = 240; $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $itemsize = 'tcol-lg-3 tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 300; $slideheight = 300; $md = 4; $sm = 3; $xs = 2; $ss = 1; } } } } } if (!empty($cat)) { $portfolio_category = $cat; } else { $portfolio_category = ''; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('orderby' => $orderby, 'order' => $order, 'post_type' => 'portfolio', 'portfolio-type' => $portfolio_category, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <div class="<?php echo $itemsize; ?> kad_product"> <div class="grid_item portfolio_item postclass"> <?php global $post; $postsummery = get_post_meta($post->ID, '_kad_post_summery', true); if ($postsummery == 'slider') { ?> <div class="flexslider imghoverclass clearfix"> <ul class="slides"> <?php $image_gallery = get_post_meta($post->ID, '_kad_image_gallery', true); $attachments = array_filter(explode(',', $image_gallery)); if ($attachments) { foreach ($attachments as $attachment) { $attachment_url = wp_get_attachment_url($attachment, 'full'); $image = aq_resize($attachment_url, $slidewidth, $slideheight, true); if (empty($image)) { $image = $attachment_url; } echo '<li><img src="' . $image . '" width="' . $slidewidth . '" height="' . $slideheight . '"/></li>'; } } ?> </ul> </div> <!--Flex Slides--> <script type="text/javascript">jQuery(window).load(function () {jQuery('.flexslider').flexslider({animation: "fade",animationSpeed: 400,slideshow: true,slideshowSpeed: 7000, before: function(slider) {slider.removeClass('loading');} }); });</script> <?php } else { if (has_post_thumbnail($post->ID)) { $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $thumbnailURL = $image_url[0]; $image = aq_resize($thumbnailURL, $slidewidth, $slideheight, true); if (empty($image)) { $image = $thumbnailURL; } ?> <div class="imghoverclass"><a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "><img src="<?php echo $image; ?> " alt="<?php the_title(); ?> " width="<?php echo $slidewidth; ?> " height="<?php echo $slideheight; ?> " class="lightboxhover" style="display: block;"></a> </div> <?php $image = null; $thumbnailURL = null; ?> <?php } } ?> <a href="<?php the_permalink(); ?> " class="portfoliolink"><div class="piteminfo"><h5><?php the_title(); ?> </h5></div></a> </div></div> <?php } } else { ?> <li class="error-not-found"><?php _e('Sorry, no portfolio entries found.', 'virtue'); ?> </li> <?php } $wp_query = null; wp_reset_query(); ?> </div></div> <?php } else { if ($type == "post") { if ($columns == '3') { $itemsize = 'tcol-lg-4 tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 400; $slideheight = 400; $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '5') { $itemsize = 'tcol-lg-25 tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 240; $slideheight = 240; $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '2') { $itemsize = 'tcol-lg-6 tcol-md-6 tcol-sm-6 tcol-xs-6 tcol-ss-12'; $slidewidth = 400; $slideheight = 400; $md = 2; $sm = 2; $xs = 2; $ss = 1; } else { if ($columns == '1') { $itemsize = 'tcol-lg-12 tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12'; $slidewidth = 400; $slideheight = 400; $md = 1; $sm = 1; $xs = 1; $ss = 1; } else { $itemsize = 'tcol-lg-3 tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 300; $slideheight = 300; $md = 4; $sm = 3; $xs = 2; $ss = 1; } } } } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('orderby' => $orderby, 'order' => $order, 'post_type' => 'post', 'category_name' => $cat, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <div class="<?php echo $itemsize; ?> kad_product"> <div <?php global $post; post_class('blog_item grid_item'); ?> > <?php if (has_post_thumbnail($post->ID)) { $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $thumbnailURL = $image_url[0]; $image = aq_resize($thumbnailURL, $slidewidth, $slideheight, true); if (empty($image)) { $image = $thumbnailURL; } } else { $thumbnailURL = virtue_post_default_placeholder(); $image = aq_resize($thumbnailURL, $slidewidth, $slideheight, true); if (empty($image)) { $image = $thumbnailURL; } ?> <?php } ?> <div class="imghoverclass"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "> <img src="<?php echo $image; ?> " alt="<?php the_title(); ?> " class="iconhover" style="display:block;"> </a> </div> <?php $image = null; $thumbnailURL = null; ?> <a href="<?php the_permalink(); ?> " class="bcarousellink"> <header> <h5 class="entry-title"><?php the_title(); ?> </h5> <div class="subhead"> <span class="postday kad-hidedate"><?php echo get_the_date('j M Y'); ?> </span> </div> </header> <div class="entry-content color_body"> <p><?php echo strip_tags(virtue_excerpt(16)); if ($readmore) { global $virtue_premium; if (!empty($virtue_premium['post_readmore_text'])) { $readmoret = $virtue_premium['post_readmore_text']; } else { $readmoret = __('Read More', 'virtue'); } echo $readmoret; } ?> </p> </div> </a> </div> </div> <?php } } else { ?> <div class="error-not-found"><?php _e('Sorry, no post entries found.', 'virtue'); ?> </div> <?php } $wp_query = null; wp_reset_query(); ?> </div> </div> <?php } else { if ($type == "featured-products") { global $woocommerce_loop; if ($columns == 1) { $md = 1; $sm = 1; $xs = 1; $ss = 1; $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; if ($columns == '2') { $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '3') { $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $md = 4; $sm = 3; $xs = 3; $ss = 1; } } } } } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'post_status' => 'publish', 'orderby' => 'menu_order', 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } ?> <?php } ?> <?php $wp_query = null; wp_reset_query(); ?> </div> </div> <?php } else { if ($type == "sale-products") { if (class_exists('woocommerce')) { global $woocommerce, $woocommerce_loop; $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); } if ($columns == 1) { $md = 1; $sm = 1; $xs = 1; $ss = 1; $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; if ($columns == '2') { $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '3') { $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $md = 4; $sm = 3; $xs = 3; $ss = 1; } } } } } if (!empty($cat)) { $product_category = $cat; } else { $product_category = ''; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale, 'post_status' => 'publish', 'product_cat' => $product_category, 'orderby' => 'menu_order', 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } ?> <?php } ?> <?php $wp_query = null; wp_reset_query(); ?> </div> </div> <?php } else { if ($type == "best-products") { global $woocommerce_loop; if ($columns == 1) { $md = 1; $sm = 1; $xs = 1; $ss = 1; $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; if ($columns == '2') { $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '3') { $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $md = 4; $sm = 3; $xs = 3; $ss = 1; } } } } } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'post_status' => 'publish', 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } ?> <?php } ?> <?php $wp_query = null; wp_reset_query(); ?> </div> </div> <?php } else { if ($type == "cat-products") { global $woocommerce_loop; if ($columns == 1) { $md = 1; $sm = 1; $xs = 1; $ss = 1; $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; if ($columns == '2') { $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '3') { $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $md = 4; $sm = 3; $xs = 3; $ss = 1; } } } } } if (!empty($cat)) { $product_category = $cat; } else { $product_category = ''; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'orderby' => $orderby, 'order' => $order, 'product_cat' => $product_category, 'post_status' => 'publish', 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } ?> <?php } ?> <?php $wp_query = null; wp_reset_query(); ?> </div> </div> <?php } } } } } } ?> <div class="clearfix"></div> <a id="prevport-<?php echo $carousel_rn; ?> " class="prev_carousel icon-arrow-left" href="#"></a> <a id="nextport-<?php echo $carousel_rn; ?> " class="next_carousel icon-arrow-right" href="#"></a> </div></div> <script type="text/javascript"> jQuery( window ).load(function () {var $wcontainer = jQuery('#carouselcontainer-<?php echo $carousel_rn; ?> '); var $container = jQuery('#carousel-<?php echo $carousel_rn; ?> '); setWidths(); function init_Carousel_widget() { $container.carouFredSel({ scroll: { <?php echo $scroll; ?> easing: "swing", duration: 700, pauseOnHover : true}, auto: {play: true, timeoutDuration: <?php echo $speed; ?> }, prev: '#prevport-<?php echo $carousel_rn; ?> ', next: '#nextport-<?php echo $carousel_rn; ?> ', pagination: false, swipe: true, items: {visible: null} }); } init_Carousel_widget(); jQuery(window).on("debouncedresize", function( event ) { $container.trigger("destroy"); setWidths(); init_Carousel_widget(); }); $wcontainer.animate({'opacity' : 1}); function getUnitWidth() {var width; if(jQuery(window).width() <= 540) { width = $wcontainer.width() / <?php echo $ss; ?> ; } else if(jQuery(window).width() <= 768) { width = $wcontainer.width() / <?php echo $xs; ?> ; } else if(jQuery(window).width() <= 990) { width = $wcontainer.width() / <?php echo $sm; ?> ; } else { width = $wcontainer.width() / <?php echo $md; ?> ; } return width; } function setWidths() { var unitWidth = getUnitWidth() -1; $container.children().css({ width: unitWidth }); } }); </script> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function WooComposer_Loop_style04($atts, $element) { global $woocommerce; $product_style = $display_elements = $quick_view_style = $img_animate = $text_align = $color_heading = $color_categories = $color_price = ''; $color_rating = $color_rating_bg = $color_quick_bg = $color_quick = $color_cart_bg = $color_cart = $color_product_desc = $advanced_opts = ''; $color_product_desc_bg = $size_title = $size_cat = $size_price = $color_on_sale = $color_on_sale_bg = $label_on_sale = $product_animation = ''; $disp_type = $category = $output = $product_style = $border_style = $border_color = $border_size = $border_radius = $lazy_images = $pagination = ''; $sale_price = $shortcode = $on_sale_alignment = $on_sale_style = $product_img_disp = ''; extract(shortcode_atts(array("disp_type" => "", "category" => "", "shortcode" => "", "product_style" => "style01", "display_elements" => "", "quick_view_style" => "expandable", "label_on_sale" => "Sale!", "text_align" => "left", "img_animate" => "rotate-clock", "pagination" => "", "color_heading" => "", "color_categories" => "", "color_price" => "", "color_rating" => "", "color_rating_bg" => "", "color_quick_bg" => "", "color_quick" => "", "color_cart_bg" => "", "color_on_sale_bg" => "", "color_on_sale" => "", "color_cart" => "", "color_product_desc" => "", "color_product_desc_bg" => "", "size_title" => "", "size_cat" => "", "size_price" => "", "border_style" => "", "border_color" => "", "border_size" => "", "border_radius" => "", "product_animation" => "", "lazy_images" => "", "advanced_opts" => "", "sale_price" => "", "on_sale_style" => "wcmp-sale-circle", "on_sale_alignment" => "wcmp-sale-right", "product_img_disp" => "single"), $atts)); $output = $heading_style = $cat_style = $price_style = $cart_style = $cart_bg_style = $view_style = $view_bg_style = $rating_style = ''; $desc_style = $label_style = $on_sale = $class = $style = $border = $desc_style = $sale_price_size = ''; $image_size = apply_filters('single_product_large_thumbnail_size', 'shop_single'); $img_animate = 'wcmp-img-' . $img_animate; if ($sale_price !== '') { $sale_price_size = 'font-size:' . $sale_price . 'px;'; } if ($border_style !== '') { $border .= 'border:' . $border_size . 'px ' . $border_style . ' ' . $border_color . ';'; $border .= 'border-radius:' . $border_radius . 'px;'; } if ($color_product_desc_bg !== '') { $desc_style .= 'background:' . $color_product_desc_bg . ';'; } if ($color_product_desc !== '') { $desc_style .= 'color:' . $color_product_desc . ';'; } $columns = 3; $display_type = $disp_type; if ($color_heading !== "") { $heading_style = 'color:' . $color_heading . ';'; } if ($size_title !== "") { $heading_style .= 'font-size:' . $size_title . 'px;'; } if ($color_categories !== "") { $cat_style = 'color:' . $color_categories . ';'; } if ($size_cat !== "") { $cat_style .= 'font-size:' . $size_cat . 'px;'; } if ($color_price !== "") { $price_style = 'color:' . $color_price . ';'; } if ($size_price !== "") { $price_style .= 'font-size:' . $size_price . 'px;'; } if ($color_rating !== "") { $rating_style .= 'color:' . $color_rating . ';'; } if ($color_rating_bg !== "") { $rating_style .= 'background:' . $color_rating_bg . ';'; } if ($color_quick_bg !== "") { $view_bg_style = 'background:' . $color_quick_bg . ';'; } if ($color_quick !== "") { $view_style = 'color:' . $color_quick . ';'; } if ($color_cart_bg !== "") { $cart_bg_style = 'background:' . $color_cart_bg . ';'; } if ($color_cart !== "") { $cart_style = 'color:' . $color_cart . ';'; } if ($color_on_sale_bg !== "") { $label_style = 'background:' . $color_on_sale_bg . ';'; } if ($color_on_sale !== "") { $label_style .= 'color:' . $color_on_sale . ';'; } $elemets = explode(",", $display_elements); if ($element == "grid") { $paged = get_query_var('paged') ? get_query_var('paged') : 1; } else { $paged = 1; } $post_count = '12'; /* $output .= do_shortcode($content); */ if ($shortcode !== '') { $new_shortcode = rawurldecode(base64_decode(strip_tags($shortcode))); } $pattern = get_shortcode_regex(); $shortcode_str = $short_atts = ''; preg_match_all("/" . $pattern . "/", $new_shortcode, $matches); $shortcode_str = str_replace('"', '', str_replace(" ", "&", trim($matches[3][0]))); $short_atts = parse_str($shortcode_str); //explode("&",$shortcode_str); if (isset($matches[2][0])) { $display_type = $matches[2][0]; } else { $display_type = ''; } if (!isset($columns)) { $columns = '4'; } if (isset($per_page)) { $post_count = $per_page; } if (isset($number)) { $post_count = $number; } if (!isset($order)) { $order = 'asc'; } if (!isset($orderby)) { $orderby = 'date'; } if (!isset($category)) { $category = ''; } if (!isset($ids)) { $ids = ''; } if ($ids) { $ids = explode(',', $ids); $ids = array_map('trim', $ids); } $col = $columns; if ($columns == "2") { $columns = 6; } elseif ($columns == "3") { $columns = 4; } elseif ($columns == "4") { $columns = 3; } $meta_query = ''; if ($display_type == "recent_products") { $meta_query = WC()->query->get_meta_query(); } if ($display_type == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } if ($display_type == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $post_count, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'meta_query' => $meta_query); if ($display_type == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } if ($display_type == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } if ($display_type == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } if ($display_type == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN')); } $test = ''; if (vc_is_inline()) { $test = "wcmp_vc_inline"; } if ($product_animation == '') { $product_animation = 'no-animation'; } else { $style .= 'opacity:1;'; } if ($element == "grid") { $class = 'vc_span' . $columns . ' '; } $output .= '<div class="woocomposer ' . $test . '" data-columns="' . $col . '">'; $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $product_id = get_the_ID(); $uid = uniqid(); $output .= '<div id="product-' . $uid . '" style="' . $style . '" class="' . $class . ' wpb_column column_container wooproduct" data-animation="animated ' . $product_animation . '">'; if ($element == 'carousel') { $output .= '<div class="wcmp-carousel-item">'; } $product_title = get_the_title($product_id); $post = get_post($product_id); $product_desc = get_post($product_id)->post_excerpt; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $rating = $product->get_rating_html(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock'; if ($product->is_on_sale()) { $on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product); } else { $on_sale = ''; } if ($quick_view_style == "expandable") { $quick_view_class = 'quick-view-loop'; } else { $quick_view_class = 'quick-view-loop-popup'; } $cat_count = sizeof(get_the_terms($product_id, 'product_cat')); $tag_count = sizeof(get_the_terms($product_id, 'product_tag')); $categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>'); $tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>'); $output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">'; $output .= "\n\t" . '<div class="wcmp-product-image">'; if (empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") { $uniqid = uniqid(); $output .= '<div class="wcmp-single-image-carousel carousel-in-loop">'; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; foreach ($attachment_ids as $attachment_id) { $product_img = wp_get_attachment_image_src($attachment_id, $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; } $output .= '</div>'; } else { $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<a href="' . get_permalink($product_id) . '"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></a>'; } if ($stock == 'OutOfStock') { $output .= "\n" . '<span class="wcmp-out-stock">' . __('Out Of Stock!', 'woocomposer') . '</span>'; } if ($on_sale !== '') { $output .= "\n" . '<div class="wcmp-onsale ' . $on_sale_alignment . ' ' . $on_sale_style . '"><span class="onsale" style="' . $label_style . ' ' . $sale_price_size . '">' . $on_sale . '</span></div>'; } $output .= '<div class="wcmp-add-to-cart" style="' . $cart_bg_style . '"><a style="' . $cart_style . '" title="Add to Cart" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-product_id="' . $product_id . '" data-product_sku="" class="add_to_cart_button product_type_simple"><i class="wooicon-cart4"></i></a></div>'; if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view ' . $quick_view_class . '" style="' . $view_bg_style . '"><a style="' . $view_style . '" title="Quick View" href="' . get_permalink($product_id) . '"><i class="wooicon-plus32"></i></a></div>'; } if (in_array("reviews", $elemets)) { $output .= "\n" . '<div class="wcmp-star-ratings" style="' . $rating_style . '">' . $rating . '</div>'; } $output .= '</div>'; $output .= "\n\t" . '<div class="wcmp-product-desc">'; $output .= '<a href="' . get_permalink($product_id) . '">'; $output .= "\n\t\t" . '<h2 style="' . $heading_style . '">' . $product_title . '</h2>'; $output .= '</a>'; if (in_array("category", $elemets)) { $output .= '<h5 style="' . $cat_style . '">'; if ($categories !== '') { $output .= $categories; $output .= $tags; } $output .= '</h5>'; } $output .= "\n\t\t" . '<div class="wcmp-price"><span class="price" style="' . $price_style . '">' . $price . '</span></div>'; if (in_array("description", $elemets)) { $output .= "\n\t\t" . '<div class="wcmp-product-content" style="' . $desc_style . '">' . $product_desc . '</div>'; } $output .= "\n\t" . '</div>'; $output .= "\n\t" . '</div>'; if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view-wrapper woocommerce" data-columns="' . $col . '">'; if ($quick_view_style !== "expandable") { $output .= '<div class="wcmp-quick-view-wrapper woocommerce product">'; $output .= '<div class="wcmp-close-single"><i class="wooicon-cross2"></i></div>'; } $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div class="wcmp-single-image wcmp-quickview-img images"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div>'; if ($quick_view_style !== "expandable") { $output .= '<div class="wcmp-product-content-single">'; } else { $output .= '<div class="wcmp-product-content">'; } ob_start(); do_action('woocommerce_single_product_summary'); $output .= ob_get_clean(); $output .= '</div>'; $output .= '<div class="clear"></div>'; if ($quick_view_style !== "expandable") { $output .= '</div>'; } $output .= '</div>'; } $output .= "\n" . '</div>'; if ($element == 'carousel') { $output .= "\n\t" . '</div>'; } } } if ($pagination == "enable") { $output .= '<div class="wcmp-paginate">'; $output .= woocomposer_pagination($query->max_num_pages); $output .= '</div>'; } $output .= '</div>'; if ($display_type == "top_rated_products") { remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); } wp_reset_postdata(); return $output; }
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { global $wp_query, $woocommerce; $cache = wp_cache_get('widget_onsale', 'widget'); if (!is_array($cache)) { $cache = array(); } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('On Sale', 'woocommerce') : $instance['title'], $instance, $this->id_base); if (!($number = (int) $instance['number'])) { $number = 10; } else { if ($number < 1) { $number = 1; } else { if ($number > 15) { $number = 15; } } } // Get products on sale $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $meta_query = $woocommerce->query->get_meta_query(); $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'orderby' => 'date', 'order' => 'ASC', 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale); $r = new WP_Query($query_args); ?> <?php if ($r->have_posts()) { ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <ul class="product_list_widget"> <?php while ($r->have_posts()) { $r->the_post(); global $product; ?> <li class="clearfix"> <?php if (has_post_thumbnail()) { ?> <figure class="featured-image img-preload img-hover post-image"> <a href="<?php echo get_permalink(); ?> "><?php echo get_the_post_thumbnail($r->post->ID, 'shop_thumbnail'); ?> <div class="overlay"></div> </a> </figure> <?php } ?> <section class="post-entry"> <div class="title"><a href="<?php echo get_permalink(); ?> "><?php echo get_the_title(); ?> </a></div> <div class="price"><?php echo $product->get_price_html(); ?> </div> </section> </li> <?php } ?> </ul> <?php echo $after_widget; ?> <?php } ?> <?php wp_reset_postdata(); $content = ob_get_clean(); if (isset($args['widget_id'])) { $cache[$args['widget_id']] = $content; } echo $content; wp_cache_set('widget_onsale', $cache, 'widget'); }
function kad_carousel_shortcode_function($atts, $content) { extract(shortcode_atts(array('type' => '', 'id' => rand(10, 100), 'columns' => '4', 'orderby' => '', 'order' => '', 'offset' => null, 'speed' => '9000', 'scroll' => '', 'portfolio_show_excerpt' => false, 'portfolio_show_types' => false, 'cat' => '', 'readmore' => false, 'items' => '8'), $atts)); if (empty($type)) { $type = 'post'; } if (empty($orderby)) { $orderby = 'menu_order'; } if (!empty($order)) { $order = $order; } else { if ($orderby == 'menu_order') { $order = 'ASC'; } else { $order = 'DESC'; } } if (!empty($cat)) { $carousel_category = $cat; } else { $carousel_category = ''; } if (empty($scroll) || $scroll == 1) { $scroll = '1'; } else { $scroll = null; } if ($columns == '2') { $itemsize = 'tcol-lg-6 tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12'; $slidewidth = 560; $slideheight = 560; $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '1') { $itemsize = 'tcol-lg-12 tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12'; $slidewidth = 560; $slideheight = 560; $md = 1; $sm = 1; $xs = 1; $ss = 1; } else { if ($columns == '3') { $itemsize = 'tcol-lg-4 tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 400; $slideheight = 400; $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '8') { $itemsize = 'tcol-lg-2 tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 200; $slideheight = 200; $md = 8; $sm = 6; $xs = 4; $ss = 2; } else { if ($columns == '6') { $itemsize = 'tcol-lg-2 tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 240; $slideheight = 240; $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $itemsize = 'tcol-lg-25 tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 240; $slideheight = 240; $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $itemsize = 'tcol-lg-3 tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 300; $slideheight = 300; $md = 4; $sm = 3; $xs = 2; $ss = 1; } } } } } } ob_start(); ?> <div class="carousel_outerrim kad-animation" data-animation="fade-in" data-delay="0"> <div class="home-margin carousel_outerrim_load fredcarousel"> <div id="carouselcontainer-<?php echo esc_attr($id); ?> " class="rowtight fadein-carousel"> <div id="carousel-<?php echo esc_attr($id); ?> " class="clearfix caroufedselclass products initcaroufedsel" data-carousel-container="#carouselcontainer-<?php echo esc_attr($id); ?> " data-carousel-transition="300" data-carousel-scroll="<?php echo esc_attr($scroll); ?> " data-carousel-auto="true" data-carousel-speed="<?php echo esc_attr($speed); ?> " data-carousel-id="<?php echo esc_attr($id); ?> " data-carousel-md="<?php echo esc_attr($md); ?> " data-carousel-sm="<?php echo esc_attr($sm); ?> " data-carousel-xs="<?php echo esc_attr($xs); ?> " data-carousel-ss="<?php echo esc_attr($ss); ?> "> <?php if ($type == "portfolio") { $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('orderby' => $orderby, 'order' => $order, 'offset' => $offset, 'post_type' => 'portfolio', 'portfolio-type' => $carousel_category, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <div class="<?php echo esc_attr($itemsize); ?> kad_product"> <div class="grid_item portfolio_item postclass"> <?php global $post; $postsummery = get_post_meta($post->ID, '_kad_post_summery', true); if ($postsummery == 'slider') { ?> <div class="flexslider kt-flexslider imghoverclass clearfix" data-flex-speed="7000" data-flex-initdelay="0" data-flex-anim-speed="400" data-flex-animation="fade" data-flex-auto="true"> <ul class="slides"> <?php $image_gallery = get_post_meta($post->ID, '_kad_image_gallery', true); $attachments = array_filter(explode(',', $image_gallery)); if ($attachments) { foreach ($attachments as $attachment) { $attachment_url = wp_get_attachment_url($attachment, 'full'); $image = aq_resize($attachment_url, $slidewidth, $slideheight, true); if (empty($image)) { $image = $attachment_url; } echo '<li><img src="' . esc_url($image) . '" width="' . esc_attr($slidewidth) . '" height="' . esc_attr($slideheight) . '"/></li>'; } } ?> </ul> </div> <!--Flex Slides--> <?php } else { if (has_post_thumbnail($post->ID)) { $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $thumbnailURL = $image_url[0]; $image = aq_resize($thumbnailURL, $slidewidth, $slideheight, true); if (empty($image)) { $image = $thumbnailURL; } ?> <div class="imghoverclass"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "> <img src="<?php echo esc_url($image); ?> " alt="<?php the_title(); ?> " width="<?php echo esc_attr($slidewidth); ?> " height="<?php echo esc_attr($slideheight); ?> " class="lightboxhover" style="display: block;"> </a> </div> <?php $image = null; $thumbnailURL = null; } } ?> <a href="<?php the_permalink(); ?> " class="portfoliolink"> <div class="piteminfo"> <h5><?php the_title(); ?> </h5> <?php if ($portfolio_show_types == true) { $terms = get_the_terms($post->ID, 'portfolio-type'); if ($terms) { ?> <p class="cportfoliotag"><?php $output = array(); foreach ($terms as $term) { $output[] = $term->name; } echo implode(', ', $output); ?> </p> <?php } } ?> <?php if ($portfolio_show_excerpt == true) { ?> <p><?php echo virtue_excerpt(16); ?> </p> <?php } ?> </div> </a> </div> </div> <?php } } else { ?> <li class="error-not-found"><?php _e('Sorry, no portfolio entries found.', 'virtue'); ?> </li> <?php } $wp_query = null; wp_reset_query(); ?> <?php } else { if ($type == "post") { $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('orderby' => $orderby, 'order' => $order, 'offset' => $offset, 'post_type' => 'post', 'category_name' => $carousel_category, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <div class="<?php echo esc_attr($itemsize); ?> kad_product"> <div <?php global $post; post_class('blog_item grid_item'); ?> > <?php if (has_post_thumbnail($post->ID)) { $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $thumbnailURL = $image_url[0]; $image = aq_resize($thumbnailURL, $slidewidth, $slideheight, true); if (empty($image)) { $image = $thumbnailURL; } } else { $thumbnailURL = virtue_post_default_placeholder(); $image = aq_resize($thumbnailURL, $slidewidth, $slideheight, true); if (empty($image)) { $image = $thumbnailURL; } } ?> <div class="imghoverclass"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "> <img src="<?php echo esc_url($image); ?> " alt="<?php the_title(); ?> " class="iconhover" style="display:block;"> </a> </div> <?php $image = null; $thumbnailURL = null; ?> <a href="<?php the_permalink(); ?> " class="bcarousellink"> <header> <h5 class="entry-title"><?php the_title(); ?> </h5> <div class="subhead"> <span class="postday kad-hidedate"><?php echo get_the_date('j M Y'); ?> </span> </div> </header> <div class="entry-content color_body"> <p> <?php echo strip_tags(virtue_excerpt(16)); if ($readmore) { global $virtue_premium; if (!empty($virtue_premium['post_readmore_text'])) { $readmoret = $virtue_premium['post_readmore_text']; } else { $readmoret = __('Read More', 'virtue'); } echo $readmoret; } ?> </p> </div> </a> </div> </div> <?php } } else { ?> <div class="error-not-found"><?php _e('Sorry, no post entries found.', 'virtue'); ?> </div> <?php } $wp_query = null; wp_reset_query(); ?> <?php } else { if ($type == "featured-products") { global $woocommerce_loop; if ($columns == 1) { $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'post_status' => 'publish', 'offset' => $offset, 'orderby' => 'menu_order', 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); woocommerce_get_template_part('content', 'product'); } } $wp_query = null; wp_reset_query(); } else { if ($type == "sale-products") { if (class_exists('woocommerce')) { global $woocommerce, $woocommerce_loop; $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); } if ($columns == 1) { $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale, 'post_status' => 'publish', 'offset' => $offset, 'product_cat' => $carousel_category, 'orderby' => 'menu_order', 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); woocommerce_get_template_part('content', 'product'); } } $wp_query = null; wp_reset_query(); } else { if ($type == "best-products") { global $woocommerce_loop; if ($columns == 1) { $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'post_status' => 'publish', 'offset' => $offset, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); woocommerce_get_template_part('content', 'product'); } } $wp_query = null; wp_reset_query(); } else { if ($type == "cat-products") { global $woocommerce_loop; if ($columns == 1) { $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'orderby' => $orderby, 'order' => $order, 'offset' => $offset, 'product_cat' => $carousel_category, 'post_status' => 'publish', 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); woocommerce_get_template_part('content', 'product'); } } $wp_query = null; wp_reset_query(); } } } } } } ?> </div> </div> <div class="clearfix"></div> <a id="prevport-<?php echo esc_attr($id); ?> " class="prev_carousel icon-arrow-left" href="#"></a> <a id="nextport-<?php echo esc_attr($id); ?> " class="next_carousel icon-arrow-right" href="#"></a> </div> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
public function rewrite_shop_page() { global $is_shop; $woocommerce_db_version = get_option('woocommerce_db_version', null); //Check rewrite this for shop page if (!$is_shop || get_option('psad_shop_page_enable') != 'yes') { return; } //Start Shop global $woocommerce, $wp_query, $wp_rewrite; $enable_product_showing_count = get_option('psad_shop_enable_product_showing_count'); $product_ids_on_sale = version_compare($woocommerce_db_version, '2.1', '<') ? woocommerce_get_product_ids_on_sale() : wc_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $global_psad_shop_product_per_page = get_option('psad_shop_product_per_page', 0); $global_psad_shop_product_show_type = get_option('psad_shop_product_show_type', ''); $global_display_type = get_option('woocommerce_category_archive_display', ''); $term = get_queried_object(); $parent_id = empty($term->term_id) ? 0 : $term->term_id; $page = 1; if (get_query_var('paged')) { $page = get_query_var('paged'); } $psad_shop_category_per_page = get_option('psad_shop_category_per_page', 0); if ($psad_shop_category_per_page <= 0) { $psad_shop_category_per_page = 3; } global $psad_queries_cached_enable; $user_roles = ''; if (is_user_logged_in()) { $user_login = wp_get_current_user(); $user_roles_a = $user_login->roles; if (is_array($user_roles_a) && count($user_roles_a) > 0) { $user_roles = implode('-', $user_roles_a); } } if (trim($user_roles) != '') { $user_roles = '_' . $user_roles; } $product_categories = false; if ($psad_queries_cached_enable == 'yes') { // Get cached shop categories query results $product_categories = get_transient('a3_s_cat' . $user_roles); } if (!$product_categories) { $args = array('parent' => $parent_id, 'child_of' => $parent_id, 'menu_order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 1, 'taxonomy' => 'product_cat', 'pad_counts' => 1); $product_categories = get_categories($args); if ($psad_queries_cached_enable == 'yes') { // Set cached shop categories query results for 1 day set_transient('a3_s_cat' . $user_roles, $product_categories, 86400); } } $numOfItems = $psad_shop_category_per_page; $to = $page * $numOfItems; $current = $to - $numOfItems; $total = sizeof($product_categories); $orderby = 'date'; $order = 'DESC'; if ($to > count($product_categories)) { $to = count($product_categories); } $psad_es_category_item_bt_type = get_option('psad_es_category_item_bt_type'); $psad_es_category_item_bt_text = esc_attr(stripslashes(get_option('psad_es_category_item_link_text', ''))); $psad_es_category_item_bt_position = get_option('psad_es_category_item_bt_position', 'bottom'); $class = 'click_more_link'; if ($psad_es_category_item_bt_type == 'button') { $class = 'click_more_button'; $psad_es_category_item_bt_text = esc_attr(stripslashes(get_option('psad_es_category_item_bt_text', ''))); } if (trim($psad_es_category_item_bt_text) == '') { $psad_es_category_item_bt_text = __('See more...', 'wc_psad'); } echo '<div style="clear:both;"></div>'; echo '<div class="pbc_container">'; echo '<div style="clear:both;"></div>'; echo '<div class="pbc_content">'; if ($product_categories) { $product_categories = array_values($product_categories); for ($i = $current; $i < $to; ++$i) { $category = $product_categories[$i]; $list_products = false; if ($psad_queries_cached_enable == 'yes') { // Get cached shop each category query results $list_products = get_transient('a3_s_p_cat_' . $category->term_id . $user_roles); } if (!$list_products) { $psad_shop_product_per_page = get_woocommerce_term_meta($category->term_id, 'psad_shop_product_per_page', true); if (!$psad_shop_product_per_page || $psad_shop_product_per_page <= 0) { $psad_shop_product_per_page = $global_psad_shop_product_per_page; } if ($psad_shop_product_per_page <= 0) { $psad_shop_product_per_page = 3; } $psad_shop_product_show_type = get_woocommerce_term_meta($category->term_id, 'psad_shop_product_show_type', true); if (!$psad_shop_product_show_type || $psad_shop_product_show_type == '') { $psad_shop_product_show_type = $global_psad_shop_product_show_type; } $display_type = get_woocommerce_term_meta($category->term_id, 'display_type', true); if (!$display_type || $display_type == '') { $display_type = $global_display_type; } if ($psad_shop_product_show_type == 'none') { } elseif ($psad_shop_product_show_type == 'recent') { } elseif ($psad_shop_product_show_type == 'onsale') { $wp_query->query_vars['post__in'] = $product_ids_on_sale; } elseif ($psad_shop_product_show_type == 'featured') { $wp_query->query_vars['no_found_rows'] = 1; $wp_query->query_vars['post_status'] = 'publish'; $wp_query->query_vars['post_type'] = 'product'; if (version_compare($woocommerce_db_version, '2.1', '>')) { $wp_query->query_vars['meta_query'] = WC()->query->get_meta_query(); } else { $wp_query->query_vars['meta_query'] = $woocommerce->query->get_meta_query(); } $wp_query->query_vars['meta_query'][] = array('key' => '_featured', 'value' => 'yes'); } $product_args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $psad_shop_product_per_page, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')), 'tax_query' => array(array('taxonomy' => 'product_cat', 'terms' => $category->slug, 'include_children' => false, 'field' => 'slug', 'operator' => 'IN'))); $ogrinal_product_args = $product_args; if ($psad_shop_product_show_type == 'onsale') { $product_args['orderby'] = 'meta_value_num date'; $product_args['order'] = 'DESC'; $product_args['meta_key'] = '_psad_onsale_order'; } elseif ($psad_shop_product_show_type == 'featured') { $product_args['orderby'] = 'meta_value_num date'; $product_args['order'] = 'DESC'; $product_args['meta_key'] = '_psad_featured_order'; } $products = query_posts($product_args); $psad_shop_drill_down = get_option('psad_shop_drill_down', 'yes'); $have_products = false; if (have_posts()) { $have_products = true; } elseif ($psad_shop_drill_down == 'yes') { $product_args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $category->slug, 'include_children' => true, 'field' => 'slug', 'operator' => 'IN')); $products = query_posts($product_args); if (have_posts()) { $have_products = true; } } $count_posts_get = count($products); $total_posts = $wp_query->found_posts; } else { $have_products = $list_products['have_products']; $count_posts_get = $list_products['count_products']; $total_posts = $list_products['total_posts']; } if ($have_products) { $term_link_html = ''; if ($category->parent > 0) { $my_term = get_term($category->parent, 'product_cat'); $term_link = get_term_link($my_term, 'product_cat'); if (is_wp_error($term_link)) { continue; } $term_link_html = '<a href="' . $term_link . '">' . $my_term->name . '</a> / '; } $term_link_sub_html = get_term_link($category->slug, 'product_cat'); echo '<div id="products_categories_row_' . $category->term_id . '" class="products_categories_row">'; echo '<div class="custom_box custom_box_archive responsi_title"><h1 class="title pbc_title">' . $term_link_html . '<a href="' . $term_link_sub_html . '">' . $category->name . '</a></h1>'; if ($enable_product_showing_count == 'yes' || $count_posts_get < $total_posts && $psad_es_category_item_bt_position == 'top') { echo '<div class="product_categories_showing_count_container">'; if ($enable_product_showing_count == 'yes') { echo '<span class="product_categories_showing_count">' . __('Showing', 'wc_psad') . ' 1 - ' . $count_posts_get . ' ' . __('of', 'wc_psad') . ' ' . $total_posts . ' ' . __('products in this Category', 'wc_psad') . '</span> '; } if ($count_posts_get < $total_posts && $psad_es_category_item_bt_position == 'top') { echo '<span class="click_more_each_categories"><a class="categories_click ' . $class . '" id="' . $category->term_id . '" href="' . $term_link_sub_html . '">' . $psad_es_category_item_bt_text . '</a></span>'; } echo '</div>'; } if (trim($category->description) != '') { echo '<blockquote class="term-description"><p>' . $category->description . '</p></blockquote>'; } echo '</div>'; if (!$list_products) { ob_start(); woocommerce_product_loop_start(); while (have_posts()) { the_post(); if (version_compare($woocommerce_db_version, '2.1', '<')) { woocommerce_get_template('content-product.php'); } else { wc_get_template('content-product.php'); } } woocommerce_product_loop_end(); $list_product_output = ob_get_clean(); echo $list_product_output; } else { echo $list_products['products_output']; } if ($psad_es_category_item_bt_position != 'top') { if ($count_posts_get < $total_posts) { echo '<div class="click_more_each_categories" style="width:100%;clear:both;"><a class="categories_click ' . $class . '" id="' . $category->term_id . '" href="' . $term_link_sub_html . '">' . $psad_es_category_item_bt_text . '</a></div>'; } else { echo '<div class="click_more_each_categories" style="width:100%;clear:both;"><span class="categories_click">' . __('No more products to view in this category', 'wc_psad') . '</span></div>'; } } echo '</div>'; echo '<div class="psad_seperator products_categories_row" style="clear:both;"></div>'; } if ($psad_queries_cached_enable == 'yes' && !$list_products) { $list_products = array('have_products' => $have_products, 'count_products' => $count_posts_get, 'total_posts' => $total_posts, 'products_output' => $list_product_output); // Set cached shop each category query results for 1 day set_transient('a3_s_p_cat_' . $category->term_id . $user_roles, $list_products, 86400); } } } echo '<div style="clear:both;"></div>'; $psad_endless_scroll_category_shop = get_option('psad_endless_scroll_category_shop'); $psad_endless_scroll_category_shop_tyle = get_option('psad_endless_scroll_category_shop_tyle'); $use_endless_scroll = false; $show_click_more = false; if ($is_shop && $psad_endless_scroll_category_shop == 'yes') { $use_endless_scroll = true; if ($psad_endless_scroll_category_shop_tyle == 'click') { $show_click_more = true; } } if (ceil($total / $numOfItems) > 1) { echo '<nav class="pagination woo-pagination woocommerce-pagination pbc_pagination">'; // fixed for 4.1.2 $defaults = array('base' => esc_url(add_query_arg('paged', '%#%')), 'format' => '', 'total' => ceil($total / $numOfItems), 'current' => $page, 'prev_text' => '←', 'next_text' => '→', 'type' => 'list', 'end_size' => 3, 'mid_size' => 3); if ($wp_rewrite->using_permalinks() && !is_search()) { $defaults['base'] = user_trailingslashit(trailingslashit(str_replace('page/' . $page, '', esc_url(add_query_arg(array('paged' => false, 'orderby' => false))))) . 'page/%#%'); } echo paginate_links($defaults); echo '</nav>'; } echo '</div><!-- pbc_content -->'; echo '<div style="clear:both;"></div>'; if ($use_endless_scroll) { $this->psad_endless_scroll_shop($show_click_more); } if ($use_endless_scroll && $show_click_more) { if (ceil($total / $numOfItems) > 1) { $psad_es_shop_bt_type = get_option('psad_es_shop_bt_type'); $psad_es_shop_bt_text = esc_attr(stripslashes(get_option('psad_es_shop_link_text', ''))); $class = 'click_more_link'; if ($psad_es_shop_bt_type == 'button') { $class = 'click_more_button'; $psad_es_shop_bt_text = esc_attr(stripslashes(get_option('psad_es_shop_bt_text', ''))); } if (trim($psad_es_shop_bt_text) == '') { $psad_es_shop_bt_text = __('Click More Categories', 'wc_psad'); } echo '<div class="pbc_content_click_more custom_box endless_click_shop"><a href="#"><a class="categories_click ' . $class . '" href="#">' . $psad_es_shop_bt_text . '</a></div>'; } } echo '<div style="clear:both;"></div>'; echo '</div><!-- pbc_container -->'; echo '<div style="clear:both;"></div>'; wp_reset_postdata(); //End Shop }
function etheme_products_shortcodes($atts, $content = null) { global $wpdb, $woocommerce_loop; if (!class_exists('Woocommerce')) { return false; } extract(shortcode_atts(array('ids' => '', 'skus' => '', 'columns' => 4, 'shop_link' => 1, 'limit' => 20, 'categories' => '', 'block_id' => false, 'product_img_hover' => '', 'type' => 'slider', 'style' => 'default', 'products' => '', 'title' => '', 'desktop' => 4, 'notebook' => 4, 'tablet' => 3, 'phones' => 1), $atts)); $args = array('post_type' => 'product', 'ignore_sticky_posts' => 1, 'no_found_rows' => 1, 'posts_per_page' => $limit, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'))); if ($products == 'featured') { $args['meta_key'] = '_featured'; $args['meta_value'] = 'yes'; } if ($products == 'new') { $args['meta_key'] = 'product_new'; $args['meta_value'] = 'enable'; } if ($products == 'sale') { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $args['post__in'] = array_merge(array(0), $product_ids_on_sale); } if ($products == 'bestsellings') { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; } if ($products == 'recently_viewed') { $viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array(); $viewed_products = array_filter(array_map('absint', $viewed_products)); if (empty($viewed_products)) { return; } $args['post__in'] = $viewed_products; $args['orderby'] = 'rand'; } if ($skus != '') { $skus = explode(',', $atts['skus']); $skus = array_map('trim', $skus); $args['meta_query'][] = array('key' => '_sku', 'value' => $skus, 'compare' => 'IN'); } if ($ids != '') { $ids = explode(',', $atts['ids']); $ids = array_map('trim', $ids); $args['post__in'] = $ids; } // Narrow by categories if ($categories != '') { $categories = explode(",", $categories); $gc = array(); foreach ($categories as $grid_cat) { array_push($gc, $grid_cat); } $gc = implode(",", $gc); ////http://snipplr.com/view/17434/wordpress-get-category-slug/ //$args['category_name'] = $gc; $pt = array('product'); $taxonomies = get_taxonomies('', 'object'); $args['tax_query'] = array('relation' => 'OR'); foreach ($taxonomies as $t) { if (in_array($t->object_type[0], $pt)) { $args['tax_query'][] = array('taxonomy' => $t->name, 'terms' => $categories, 'field' => 'id'); } } } $customItems = array('desktop' => $desktop, 'notebook' => $notebook, 'tablet' => $tablet, 'phones' => $phones); $woocommerce_loop['hover'] = $product_img_hover; if ($type == 'slider') { $slider_args = array('title' => $title, 'shop_link' => $shop_link, 'slider_type' => false, 'items' => $customItems, 'style' => $style); ob_start(); etheme_create_slider($args, $slider_args); $output = ob_get_contents(); ob_end_clean(); } elseif ($type == 'full-width') { $slider_args = array('title' => $title, 'shop_link' => $shop_link, 'slider_type' => 'swiper', 'customItems' => $customItems, 'style' => $style, 'block_id' => $block_id); ob_start(); etheme_create_slider($args, $slider_args); $output = ob_get_contents(); ob_end_clean(); } else { $woocommerce_loop['view_mode'] = $type; $output = etheme_products($args, $title, $columns); } unset($woocommerce_loop['hover']); return $output; }
public function build_search_query($_FIELDS) { global $pw_woo_ad_main_class; global $_chosen_attributes, $wpdb, $wp; $your_search = array(); $rand_id = isset($_FIELDS['pw_sf_rand_id']) ? $_FIELDS['pw_sf_rand_id'] : ''; $pw_sf_part = isset($_FIELDS['pw_sf_part']) ? $_FIELDS['pw_sf_part'] : ''; $query_posts_per_page = 10; $query_post_type = 'properties'; $query_meta_key = ''; $query_orderby = 'date'; $query_order = 'ASC'; $pw_order = ''; $pw_orderby = ''; $query_by_id_in = ''; $query_by_id_not_in = ''; $query_taxonomies = array(); //FETCH ALL SHORTCODE DETAILS $pw_woo_ad_main_class->fetch_custom_fields($_FIELDS['pw_sf_shortcode_id']); //APPLY BUILD QUERY TAX/Cat Filter item FOR GRID AND SEARCH_with_buildquery $query_tax_query = array('relation' => 'AND'); $query_meta_query = array('relation' => 'AND'); $include_tax_build_query = ''; $exclude_tax_build_query = ''; if ($pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'shortcode_type'] != 'search') { $pw_query = $this->check_isset(__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'build_query_taxonomy', 'custom_field', ''); if ($build_query_type = $pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'fetch_type'] == 'build_query') { if (isset($pw_query['taxonomy_checkbox'])) { $taxonomies = $pw_query['taxonomy_checkbox']; foreach ($taxonomies as $taxonomy) { if (isset($pw_query['in_' . $taxonomy])) { $taxonomy_value = $pw_query['in_' . $taxonomy]; $include_tax_build_query[$taxonomy] = $taxonomy_value; } if (isset($pw_query['ex_' . $taxonomy])) { $taxonomy_value = $pw_query['ex_' . $taxonomy]; $exclude_tax_build_query[$taxonomy] = $taxonomy_value; } } } if (isset($pw_query['in_ids'])) { $query_by_id_in = $pw_query['in_ids']; } if (isset($pw_query['ex_ids'])) { $query_by_id_not_in = $pw_query['ex_ids']; } } else { $pw_query = $this->check_isset(__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'build_query_taxonomy', 'custom_field', ''); if ($build_query_type = $pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'fetch_type'] == 'build_query') { if (isset($pw_query['taxonomy_checkbox'])) { $taxonomies = $pw_query['taxonomy_checkbox']; foreach ($taxonomies as $taxonomy) { if (isset($pw_query['in_' . $taxonomy])) { $taxonomy_value = $pw_query['in_' . $taxonomy]; $include_tax_build_query[$taxonomy] = $taxonomy_value; } if (isset($pw_query['ex_' . $taxonomy])) { $taxonomy_value = $pw_query['ex_' . $taxonomy]; $exclude_tax_build_query[$taxonomy] = $taxonomy_value; } } } if (isset($pw_query['in_ids'])) { $query_by_id_in = $pw_query['in_ids']; } if (isset($pw_query['ex_ids'])) { $query_by_id_not_in = $pw_query['ex_ids']; } } else { $fetch_type = $build_query_type = $pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'fetch_type']; switch ($fetch_type) { case "on_sale_product": $query_by_id_in = woocommerce_get_product_ids_on_sale(); $query_by_id_in[] = 0; break; case "in_stock_product": $query_meta_query[] = array('key' => '_stock_status', 'value' => "instock", 'compare' => '='); break; case "out_stock_product": $query_meta_query[] = array('key' => '_stock_status', 'value' => "outofstock", 'compare' => '='); break; } /////////Your Search////////// /*$your_search_span='<span id="'.$fetch_type.'" class="ys_items" data-target-element="product_status" data-rand-id="'.$rand_id.'">'.$fetch_type.' <i class="fa fa-times"></i></span>'; /////////Your Search////////// $your_search['product_status']='<span id="ys_product_status" >'.__('Product Status',__PW_WOO_AD_SEARCH_TEXTDOMAIN__).' : '.$your_search_span.'</span>'; */ } } $query_meta_key = ''; $query_orderby = ''; if (isset($pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'build_query_order_by'])) { $pw_query_order = $pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'build_query_order_by']; $public_orders_array = array('ID', 'date', 'author', 'title', 'modified', 'rand', 'comment_count', 'menu_order'); if (in_array($pw_query_order, $public_orders_array)) { $query_orderby = $pw_query_order; } else { $query_meta_key = $pw_query_order; $query_orderby = 'meta_value_num'; } } $query_order = ''; if (isset($pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'build_query_order_type'])) { $query_order = $pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'build_query_order_type']; } $pw_meta_key = $query_meta_key; $pw_orderby = $query_orderby; $pw_order = $query_order; //Show Hidden Products(s) if (!isset($pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'show_hidden_product'])) { $query_meta_query[] = array('key' => '_visibility', 'value' => 'visible', 'compare' => '='); } //Just Featured products(s) if (isset($pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'featured_product'])) { $query_meta_query[] = array('key' => '_featured', 'value' => 'yes', 'compare' => '='); } //Hide Free products(s) if (isset($pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'hide_free_product'])) { $query_meta_query[] = array('key' => '_price', 'value' => '', 'compare' => '!='); } } //FOR PROPERTY TAXONOMY ARCHIVE PAGE. Example: property_type/apartment/ or contract_type/rent/ if (isset($_FIELDS['pw_sf_taxonomy']) && $_FIELDS['pw_sf_taxonomy'] != '') { $query_tax_query[] = array('taxonomy' => $_FIELDS['pw_sf_taxonomy'], 'field' => 'id', 'terms' => array($_FIELDS['pw_sf_taxonomy_id']), 'operator' => 'IN'); } $post_name = $_FIELDS['pw_sf_post_type']; $option_data = ''; $param_line = ''; $all_tax = get_object_taxonomies($post_name); $current_value = array(); if (is_array($all_tax) && count($all_tax) > 0) { $post_type_label = get_post_type_object($post_name); $label = $post_type_label->label; $param_line .= '<div style=" text-transform:uppercase;border-bottom:2px solid #333;width:100%;margin:20px 0px">' . $label . ' Taxonomies</div>'; //FETCH TAXONOMY foreach ($all_tax as $tax) { $taxonomy = get_taxonomy($tax); $values = $tax; $label = $taxonomy->label; if (isset($_FIELDS[$tax]) && !empty($_FIELDS[$tax])) { $property_type = $_FIELDS[$tax]; if (isset($include_tax_build_query[$tax])) { $property_type = array_merge($_FIELDS[$tax], $include_tax_build_query[$tax]); } if (count(array_filter($property_type)) > 0 && !in_array('0', $property_type)) { $query_tax_query[] = array('taxonomy' => $tax, 'field' => 'id', 'terms' => $property_type, 'operator' => 'IN'); if (isset($exclude_tax_build_query[$tax])) { $property_type = $exclude_tax_build_query[$tax]; $query_tax_query[] = array('taxonomy' => $tax, 'field' => 'id', 'terms' => $property_type, 'operator' => 'Not IN'); } } /////////Your Search////////// if (count(array_filter($property_type)) > 0) { $your_search_span = ''; foreach ($property_type as $ys_items) { $tax_name = get_term_by('id', $ys_items, $tax); $tax_name = $tax_name->name; $your_search_span .= '<span id="' . $ys_items . '" class="ys_items" data-target-element="' . $tax . '" data-rand-id="' . $rand_id . '">' . $tax_name . ' <i class="fa fa-times"></i></span>'; } $your_search[$tax] = '<span id="ys_' . $tax . '" >' . __($label, __PW_WOO_AD_SEARCH_TEXTDOMAIN__) . ' : ' . $your_search_span . '</span>'; } } else { if (isset($include_tax_build_query[$tax])) { $property_type = $include_tax_build_query[$tax]; $query_tax_query[] = array('taxonomy' => $tax, 'field' => 'id', 'terms' => $property_type, 'operator' => 'IN'); } if (isset($exclude_tax_build_query[$tax])) { $property_type = $exclude_tax_build_query[$tax]; $query_tax_query[] = array('taxonomy' => $tax, 'field' => 'id', 'terms' => $property_type, 'operator' => 'Not IN'); } } } } //////GET MIN AND MAX PRICE///////////// $min = floor($wpdb->get_var($wpdb->prepare(' SELECT min(meta_value + 0) FROM %1$s LEFT JOIN %2$s ON %1$s.ID = %2$s.post_id WHERE ( meta_key = \'%3$s\' OR meta_key = \'%4$s\' ) AND meta_value != "" ', $wpdb->posts, $wpdb->postmeta, '_price', '_min_variation_price'))); $max = ceil($wpdb->get_var($wpdb->prepare(' SELECT max(meta_value + 0) FROM %1$s LEFT JOIN %2$s ON %1$s.ID = %2$s.post_id WHERE meta_key = \'%3$s\' ', $wpdb->posts, $wpdb->postmeta, '_price'))); //Sale Price Range - Price Type $from_main_price = isset($_FIELDS['search_from_main_price_range']) ? esc_attr($_FIELDS['search_from_main_price_range']) : ''; $from_main_price = $from_main_price != $min ? $from_main_price : ''; $to_main_price = isset($_FIELDS['search_to_main_price_range']) ? esc_attr($_FIELDS['search_to_main_price_range']) : ''; $to_main_price = $to_main_price != $max ? $to_main_price : ''; $price_type = '_price'; /*if($to_main_price=='' && $from_main_price=='') { $query_meta_query[]= array( 'key' => $price_type, 'value' => '', 'compare' => '!=' ); }else */ if ($to_main_price != '' && $from_main_price != '') { $query_meta_query[] = array('key' => $price_type, 'value' => array($from_main_price, $to_main_price), 'type' => 'numeric', 'compare' => 'BETWEEN'); /////////Your Search////////// $your_search['from_main_price_range'] = '<span id="ys_main_price_range" >' . __('Price Ragne(From)', __PW_WOO_AD_SEARCH_TEXTDOMAIN__) . ' : <span class="ys_items" data-target-element="from_main_price_range" data-rand-id="' . $rand_id . '">' . $from_main_price . ' <i class="fa fa-times"></i></span></span>'; $your_search['to_main_price_range'] = '<span id="ys_main_price_range" >' . __('Price Ragne(To)', __PW_WOO_AD_SEARCH_TEXTDOMAIN__) . ' : <span class="ys_items" data-target-element="to_main_price_range" data-rand-id="' . $rand_id . '">' . $to_main_price . ' <i class="fa fa-times"></i></span></span>'; } else { if ($to_main_price == '' && $from_main_price != '') { $query_meta_query[] = array('key' => $price_type, 'value' => $from_main_price, 'type' => 'numeric', 'compare' => '>='); /////////Your Search////////// $your_search['from_main_price_range'] = '<span id="ys_main_price_range" >' . __('Price Ragne(From)', __PW_WOO_AD_SEARCH_TEXTDOMAIN__) . ' : <span class="ys_items" data-target-element="from_main_price_range" data-rand-id="' . $rand_id . '">' . $from_main_price . ' <i class="fa fa-times"></i></span></span>'; } else { if ($to_main_price != '' && $from_main_price == '') { $query_meta_query[] = array('key' => $price_type, 'value' => $to_main_price, 'type' => 'numeric', 'compare' => '<='); /////////Your Search////////// $your_search['to_main_price_range'] = '<span id="ys_main_price_range" >' . __('Price Ragne(To)', __PW_WOO_AD_SEARCH_TEXTDOMAIN__) . ' : <span class="ys_items" data-target-element="to_main_price_range" data-rand-id="' . $rand_id . '">' . $to_main_price . ' <i class="fa fa-times"></i></span></span>'; } } } //$query_meta_query=array('relation' => 'AND'); //Product Status if (isset($_FIELDS['product_status']) && !empty($_FIELDS['product_status'])) { $product_status = $_FIELDS['product_status']; $your_search_span = ''; foreach ($product_status as $status) { $arr_status = explode('#', $status); $status_value = $arr_status[0]; $status_lbl = $arr_status[1]; switch ($status_value) { case "product_status_featured": $query_meta_query[] = array('key' => '_featured', 'value' => 'yes', 'compare' => '='); break; case "product_status_onsale": $query_by_id_in = woocommerce_get_product_ids_on_sale(); $query_by_id_in[] = 0; break; case "product_status_instock": $query_meta_query[] = array('key' => '_stock_status', 'value' => "instock", 'compare' => '='); break; case "product_status_outstock": $query_meta_query[] = array('key' => '_stock_status', 'value' => "outofstock", 'compare' => '='); break; } /////////Your Search////////// $your_search_span .= '<span id="' . $status . '" class="ys_items" data-target-element="product_status" data-rand-id="' . $rand_id . '">' . $status_lbl . ' <i class="fa fa-times"></i></span>'; } /////////Your Search////////// $your_search['product_status'] = '<span id="ys_product_status" >' . __('Product Status', __PW_WOO_AD_SEARCH_TEXTDOMAIN__) . ' : ' . $your_search_span . '</span>'; } //print_r($_FIELDS); //TITLE $query_title = ''; if (isset($_FIELDS['title']) && !empty($_FIELDS['title'])) { $query_title = esc_attr($_FIELDS['title']); /////////Your Search////////// $your_search['title'] = '<span id="ys_title" >' . __('Title', __PW_WOO_AD_SEARCH_TEXTDOMAIN__) . ' : <span class="ys_items" data-target-element="title" data-rand-id="' . $rand_id . '">' . $query_title . ' <i class="fa fa-times"></i></span></span>'; } //ORDER if (isset($_FIELDS['pw_sf_order']) && !empty($_FIELDS['pw_sf_order'])) { $pw_order = esc_attr($_FIELDS['pw_sf_order']); } if (isset($_FIELDS['pw_sf_orderby']) && !empty($_FIELDS['pw_sf_orderby'])) { $pw_meta_key = ''; $pw_orderby = ''; $pw_orderby = esc_attr($_FIELDS['pw_sf_orderby']); $public_orders_array = array('ID', 'date', 'author', 'title', 'modified', 'rand', 'comment_count', 'menu_order'); if (!in_array($pw_orderby, $public_orders_array)) { $pw_meta_key = $pw_orderby; $pw_orderby = 'meta_value_num'; } } //die(print_r($_FIELDS)); //PAGINATION $pw_post_per_page = -1; if (isset($_FIELDS['pw_sf_post_per_page']) && !empty($_FIELDS['pw_sf_post_per_page'])) { $pw_post_per_page = esc_attr($_FIELDS['pw_sf_post_per_page']); } $pw_paged = 1; if (isset($_FIELDS['pw_sf_pagination_paged']) && !empty($_FIELDS['pw_sf_pagination_paged'])) { $pw_paged = esc_attr($_FIELDS['pw_sf_pagination_paged']); } //POST TYPE $post_type = 'post'; if (isset($_FIELDS['pw_sf_post_type']) && !empty($_FIELDS['pw_sf_post_type'])) { $post_type = esc_attr($_FIELDS['pw_sf_post_type']); } if (isset($pw_woo_ad_main_class->custom_field[__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'hide_recent_post'])) { $query_posts_recent = $pw_woo_ad_main_class->check_isset(__PW_WOO_AD_SEARCH_FIELDS_PERFIX__ . 'hide_recent_post_num', 'custom_field', '1'); $args = array('post_type' => $post_type, 'post_status' => 'publish', 'posts_per_page' => $query_posts_recent, 'orderby' => 'date', 'order' => 'DESC', 'search_title' => $query_title, 'meta_query' => $query_meta_query, 'tax_query' => $query_tax_query, 'post__in' => $query_by_id_in, 'post__not_in' => $query_by_id_not_in); $my_query = new WP_Query($args); $recent_posts = array(); while ($my_query->have_posts()) { $my_query->the_post(); $recent_posts[] = get_the_ID(); } if (is_array($query_by_id_not_in)) { $query_by_id_not_in = array_merge($query_by_id_not_in, $recent_posts); } else { $query_by_id_not_in = $recent_posts; } } if (strtolower($pw_post_per_page) == 'all') { $pw_post_per_page = "-1"; } //Build Query $args = array('post_type' => $post_type, 'post_status' => 'publish', 'posts_per_page' => $pw_post_per_page, 'meta_key' => $pw_meta_key, 'orderby' => $pw_orderby, 'order' => $pw_order, 'paged' => $pw_paged, 'search_title' => $query_title, 'meta_query' => $query_meta_query, 'tax_query' => $query_tax_query, 'post__in' => $query_by_id_in, 'post__not_in' => $query_by_id_not_in); //die(print_r($args)); //print_r($args); global $paged; $paged = $pw_paged; $return_value = array(); $return_value['query'] = $args; $return_value['your_search'] = $your_search; return $return_value; }
/** * is_valid function. * * Check if a coupon is valid. Return a reason code if invalid. Reason codes: * * @access public * @return bool|WP_Error validity or a WP_Error if not valid */ public function is_valid() { global $woocommerce; $error_code = null; $valid = true; $error = false; if ($this->id) { // Usage Limit if ($this->usage_limit > 0) { if ($this->usage_count >= $this->usage_limit) { $valid = false; $error_code = self::E_WC_COUPON_USAGE_LIMIT_REACHED; } } // Expired if ($this->expiry_date) { if (current_time('timestamp') > $this->expiry_date) { $valid = false; $error_code = self::E_WC_COUPON_EXPIRED; } } // Minimum spend if ($this->minimum_amount > 0) { if ($this->minimum_amount > $woocommerce->cart->subtotal) { $valid = false; $error_code = self::E_WC_COUPON_MIN_SPEND_LIMIT_NOT_MET; } } // Product ids - If a product included is found in the cart then its valid if (sizeof($this->product_ids) > 0) { $valid_for_cart = false; if (sizeof($woocommerce->cart->get_cart()) > 0) { foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { if (in_array($cart_item['product_id'], $this->product_ids) || in_array($cart_item['variation_id'], $this->product_ids) || in_array($cart_item['data']->get_parent(), $this->product_ids)) { $valid_for_cart = true; } } } if (!$valid_for_cart) { $valid = false; $error_code = self::E_WC_COUPON_NOT_APPLICABLE; } } // Category ids - If a product included is found in the cart then its valid if (sizeof($this->product_categories) > 0) { $valid_for_cart = false; if (sizeof($woocommerce->cart->get_cart()) > 0) { foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { $product_cats = wp_get_post_terms($cart_item['product_id'], 'product_cat', array("fields" => "ids")); if (sizeof(array_intersect($product_cats, $this->product_categories)) > 0) { $valid_for_cart = true; } } } if (!$valid_for_cart) { $valid = false; $error_code = self::E_WC_COUPON_NOT_APPLICABLE; } } // Cart discounts cannot be added if non-eligble product is found in cart if ($this->type != 'fixed_product' && $this->type != 'percent_product') { // Exclude Products if (sizeof($this->exclude_product_ids) > 0) { $valid_for_cart = true; if (sizeof($woocommerce->cart->get_cart()) > 0) { foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { if (in_array($cart_item['product_id'], $this->exclude_product_ids) || in_array($cart_item['variation_id'], $this->exclude_product_ids) || in_array($cart_item['data']->get_parent(), $this->exclude_product_ids)) { $valid_for_cart = false; } } } if (!$valid_for_cart) { $valid = false; $error_code = self::E_WC_COUPON_NOT_APPLICABLE; } } // Exclude Sale Items if ($this->exclude_sale_items == 'yes') { $valid_for_cart = true; $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); if (sizeof($woocommerce->cart->get_cart()) > 0) { foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { if (in_array($cart_item['product_id'], $product_ids_on_sale, true) || in_array($cart_item['variation_id'], $product_ids_on_sale, true) || in_array($cart_item['data']->get_parent(), $product_ids_on_sale, true)) { $valid_for_cart = false; } } } if (!$valid_for_cart) { $valid = false; $error_code = self::E_WC_COUPON_NOT_VALID_SALE_ITEMS; } } // Exclude Categories if (sizeof($this->exclude_product_categories) > 0) { $valid_for_cart = true; if (sizeof($woocommerce->cart->get_cart()) > 0) { foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { $product_cats = wp_get_post_terms($cart_item['product_id'], 'product_cat', array("fields" => "ids")); if (sizeof(array_intersect($product_cats, $this->exclude_product_categories)) > 0) { $valid_for_cart = false; } } } if (!$valid_for_cart) { $valid = false; $error_code = self::E_WC_COUPON_NOT_APPLICABLE; } } } $valid = apply_filters('woocommerce_coupon_is_valid', $valid, $this); if ($valid) { return true; } else { $error_code = self::E_WC_COUPON_INVALID_FILTERED; } } else { $error_code = self::E_WC_COUPON_NOT_EXIST; } if ($error_code) { $this->error_message = $this->get_coupon_error($error_code); } return false; }
function kad_carousel_shortcode_function($atts, $content) { extract(shortcode_atts(array('type' => '', 'columns' => '4', 'orderby' => '', 'speed' => '9000', 'scroll' => '', 'cat' => '', 'fullwidth' => 'standard', 'readmore' => false, 'ratio' => 'defualt', 'items' => '8'), $atts)); $carousel_rn = rand(10, 100); if (empty($type)) { $type = 'post'; } if (empty($orderby)) { $orderby = 'menu_order'; } if ($orderby == 'menu_order') { $order = 'ASC'; } else { $order = 'DESC'; } if (empty($cat)) { $cat = ''; } if (empty($scroll) || $scroll == 1) { $scroll = 'items:1,'; } else { $scroll = ''; } global $pinnacle; if (isset($pinnacle['product_shop_style'])) { $product_shop_style = $pinnacle['product_shop_style']; } else { $product_shop_style = 'kad-simple-shop'; } if ($type == "portfolio") { if (isset($pinnacle['portfolio_style_default'])) { $pstyleclass = $pinnacle['portfolio_style_default']; } else { $pstyleclass = 'padded_style'; } if (isset($pinnacle['portfolio_hover_style_default'])) { $phoverstyleclass = $pinnacle['portfolio_hover_style_default']; } else { $phoverstyleclass = 'p_lightstyle'; } $shortcodeclasses[] = $pstyleclass; $shortcodeclasses[] = $phoverstyleclass; $shortcodeclasses[] = 'kt-portfolio-carousel'; if (isset($pinnacle['portfolio_viewdetails_text']) && !empty($pinnacle['portfolio_viewdetails_text'])) { $viewdetails = $pinnacle['portfolio_viewdetails_text']; } else { $viewdetails = __('View details', 'pinnacle'); } } else { $shortcodeclasses[] = ''; } ob_start(); ?> <div class="carousel_outerrim kad-animation" data-animation="fade-in" data-delay="0"> <div class="home-margin fredcarousel"> <div id="carouselcontainer-<?php echo esc_attr($carousel_rn); ?> " class="rowtight <?php echo implode(" ", $shortcodeclasses); ?> fadein-carousel"> <div id="carousel-<?php echo esc_attr($carousel_rn); ?> " class="clearfix <?php echo esc_attr($product_shop_style); ?> blog_carousel caroufedselclass products"> <?php if ($type == "portfolio") { if (isset($pinnacle['portfolio_ratio_default'])) { $pimgratio = $pinnacle['portfolio_ratio_default']; } else { $pimgratio = "square"; } if ($fullwidth == 'fullwidth') { if ($columns == '2') { $itemsize = 'tcol-sxl-3 tcol-xl-4 tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12'; $slidewidth = 700; $sxl = 4; $xl = 3; $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '3') { $itemsize = 'tcol-sxl-25 tcol-xl-3 tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 460; $sxl = 5; $xl = 4; $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $itemsize = 'tcol-sxl-2 tcol-xl-2 tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 300; $sxl = 6; $xl = 6; $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $itemsize = 'tcol-sxl-2 tcol-xl-2 tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 300; $sxl = 6; $xl = 6; $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $itemsize = 'tcol-sxl-2 tcol-xl-25 tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 360; $sxl = 6; $xl = 5; $md = 4; $sm = 3; $xs = 2; $ss = 1; } } } } } else { if ($columns == '2') { $itemsize = 'tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12'; $slidewidth = 600; $sxl = 2; $xl = 2; $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '3') { $itemsize = 'tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 400; $sxl = 3; $xl = 3; $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $itemsize = 'tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 300; $sxl = 6; $xl = 6; $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $itemsize = 'tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $slidewidth = 300; $sxl = 5; $xl = 5; $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $itemsize = 'tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $slidewidth = 300; $sxl = 4; $xl = 4; $md = 4; $sm = 3; $xs = 2; $ss = 1; } } } } } if ($pimgratio == 'portrait') { $temppimgheight = $slidewidth * 1.35; $slideheight = floor($temppimgheight); } else { if ($pimgratio == 'landscape') { $temppimgheight = $slidewidth / 1.35; $slideheight = floor($temppimgheight); } else { if ($pimgratio == 'widelandscape') { $temppimgheight = $slidewidth / 2; $slideheight = floor($temppimgheight); } else { $slideheight = $slidewidth; } } } global $kt_portfolio_loop; $kt_portfolio_loop = array('lightbox' => 'false', 'showexcerpt' => 'false', 'showtypes' => 'true', 'pstyleclass' => $pstyleclass, 'viewdetails' => $viewdetails, 'slidewidth' => $slidewidth, 'slideheight' => $slideheight); if (!empty($cat)) { $portfolio_category = $cat; } else { $portfolio_category = ''; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('orderby' => $orderby, 'order' => $order, 'post_type' => 'portfolio', 'portfolio-type' => $portfolio_category, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <div class="<?php echo esc_attr($itemsize); ?> all p-item"> <?php do_action('kadence_portfolio_loop_start'); get_template_part('templates/content', 'loop-portfolio'); do_action('kadence_portfolio_loop_start'); ?> </div> <?php } } else { ?> <li class="error-not-found"><?php _e('Sorry, no portfolio entries found.', 'pinnacle'); ?> </li> <?php } $wp_query = null; wp_reset_query(); ?> </div></div> <?php } else { if ($type == "post") { global $postcolumn; if ($columns == '2') { $itemsize = 'tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12'; $postcolumn = '2'; $md = 2; $sm = 2; $xs = 2; $ss = 1; } else { if ($columns == '3') { $itemsize = 'tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $postcolumn = '3'; $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '1') { $itemsize = 'tcol-lg-12 tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12'; $postcolumn = '1'; $md = 1; $sm = 1; $xs = 1; $ss = 1; } else { $itemsize = 'tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $postcolumn = '4'; $md = 4; $sm = 3; $xs = 2; $ss = 1; } } } $sxl = $md; $xl = $md; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('orderby' => $orderby, 'order' => $order, 'post_type' => 'post', 'category_name' => $cat, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <div class="<?php echo $itemsize; ?> b_item kad_blog_item"> <?php get_template_part('templates/content', 'post-grid-carousel'); ?> </div> <?php } } else { ?> <div class="error-not-found"><?php _e('Sorry, no post entries found.', 'pinnacle'); ?> </div> <?php } $wp_query = null; wp_reset_query(); ?> </div> </div> <?php } else { if ($type == "featured-products") { global $woocommerce_loop; if ($columns == 1) { $md = 1; $sm = 1; $xs = 1; $ss = 1; $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; if ($columns == '2') { $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '3') { $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $md = 4; $sm = 3; $xs = 3; $ss = 1; } } } } } $sxl = $md; $xl = $md; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'post_status' => 'publish', 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } ?> <?php } ?> <?php $wp_query = null; wp_reset_query(); ?> </div> </div> <?php } else { if ($type == "sale-products") { if (class_exists('woocommerce')) { global $woocommerce, $woocommerce_loop; $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $product_ids_on_sale[] = 0; $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); } if ($columns == 1) { $md = 1; $sm = 1; $xs = 1; $ss = 1; $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; if ($columns == '2') { $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '3') { $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $md = 4; $sm = 3; $xs = 3; $ss = 1; } } } } } $sxl = $md; $xl = $md; if (!empty($cat)) { $product_category = $cat; } else { $product_category = ''; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_query' => $meta_query, 'post__in' => $product_ids_on_sale, 'product_cat' => $product_category, 'post_status' => 'publish', 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } ?> <?php } ?> <?php $wp_query = null; wp_reset_query(); ?> </div> </div> <?php } else { if ($type == "best-products") { global $woocommerce_loop; if ($columns == 1) { $md = 1; $sm = 1; $xs = 1; $ss = 1; $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; if ($columns == '2') { $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '3') { $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $md = 4; $sm = 3; $xs = 3; $ss = 1; } } } } } $sxl = $md; $xl = $md; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'post_status' => 'publish', 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } ?> <?php } ?> <?php $wp_query = null; wp_reset_query(); ?> </div> </div> <?php } else { if ($type == "cat-products") { global $woocommerce_loop; if ($columns == 1) { $md = 1; $sm = 1; $xs = 1; $ss = 1; $woocommerce_loop['columns'] = 3; } else { $woocommerce_loop['columns'] = $columns; if ($columns == '2') { $md = 2; $sm = 2; $xs = 1; $ss = 1; } else { if ($columns == '3') { $md = 3; $sm = 3; $xs = 2; $ss = 1; } else { if ($columns == '6') { $md = 6; $sm = 4; $xs = 3; $ss = 2; } else { if ($columns == '5') { $md = 5; $sm = 4; $xs = 3; $ss = 2; } else { $md = 4; $sm = 3; $xs = 3; $ss = 1; } } } } } $sxl = $md; $xl = $md; if (!empty($cat)) { $product_category = $cat; } else { $product_category = ''; } $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array('post_type' => 'product', 'orderby' => $orderby, 'order' => $order, 'product_cat' => $product_category, 'post_status' => 'publish', 'posts_per_page' => $items)); if ($wp_query) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php } ?> <?php } ?> <?php $wp_query = null; wp_reset_query(); ?> </div> </div> <?php } } } } } } ?> <div class="clearfix"></div> <a id="prevport-<?php echo $carousel_rn; ?> " class="prev_carousel kt-icon-arrow-left" href="#"></a> <a id="nextport-<?php echo $carousel_rn; ?> " class="next_carousel kt-icon-arrow-right" href="#"></a> </div></div> <script type="text/javascript"> jQuery( window ).load(function () {var $wcontainer = jQuery('#carouselcontainer-<?php echo $carousel_rn; ?> '); var $container = jQuery('#carousel-<?php echo $carousel_rn; ?> '); setWidths(); function initCarousel_short() { $container.carouFredSel({ scroll: { <?php echo $scroll; ?> easing: "swing", duration: 700, pauseOnHover : true}, auto: {play: true, timeoutDuration: <?php echo $speed; ?> }, prev: '#prevport-<?php echo $carousel_rn; ?> ', next: '#nextport-<?php echo $carousel_rn; ?> ', pagination: false, swipe: true, items: {visible: null} }); } initCarousel_short(); jQuery(window).on("debouncedresize", function( event ) { $container.trigger("destroy"); setWidths(); initCarousel_short(); }); $wcontainer.animate({'opacity' : 1}); function getUnitWidth() {var width; if(jQuery(window).width() <= 540) { width = $wcontainer.width() / <?php echo $ss; ?> ; } else if(jQuery(window).width() <= 768) { width = $wcontainer.width() / <?php echo $xs; ?> ; } else if(jQuery(window).width() <= 990) { width = $wcontainer.width() / <?php echo $sm; ?> ; } else if(jQuery(window).width() >= 1800) { width = $wcontainer.width() / <?php echo $sxl; ?> ; }else if(jQuery(window).width() >= 1400) { width = $wcontainer.width() / <?php echo $xl; ?> ; } else { width = $wcontainer.width() / <?php echo $md; ?> ; } return width; } function setWidths() { var unitWidth = getUnitWidth() -1; $container.children().css({ width: unitWidth }); } }); </script> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function woocomposer_list_shortcode($atts) { global $woocommerce; $img_position = $img_size = $img_border = $border_size = $border_radius = $border_color = $title_font = $price_font = $price_color = $rating_color = $rating_font = $shortcode = ''; extract(shortcode_atts(array("img_position" => "", "shortcode" => "", "img_size" => "", "img_border" => "", "border_size" => "", "border_radius" => "", "border_color" => "", "title_color" => "", "title_font" => "", "price_font" => "", "price_color" => "", "rating_color" => "", "rating_font" => ""), $atts)); $output = $on_sale = $style = $title_style = $pricing_style = $rating_style = ''; if ($img_size !== "") { $style .= 'width:' . $img_size . 'px; height:' . $img_size . 'px;'; } if ($title_color !== "") { $title_style .= 'color:' . $title_color . ';'; } if ($title_font !== "") { $title_style .= 'font-size:' . $title_font . 'px;'; } if ($img_border !== '') { $style .= 'border-style:' . $img_border . ';'; if ($border_size !== '') { $style .= 'border-width:' . $border_size . 'px;'; } if ($border_color !== '') { $style .= 'border-color:' . $border_color . ';'; } if ($border_radius !== '') { $style .= 'border-radius:' . $border_radius . 'px;'; } } if ($price_font !== "") { $pricing_style .= 'font-size:' . $price_font . 'px;'; } if ($price_color !== "") { $pricing_style .= 'color:' . $price_color . ';'; } if ($rating_color !== "") { $rating_style .= 'color:' . $rating_color . ';'; } if ($rating_font !== "") { $rating_style .= 'font-size:' . $rating_font . 'px;'; } $post_count = '12'; $output .= '<div class="woocomposer_list woocommerce">'; /* $output .= do_shortcode($content); */ $pattern = get_shortcode_regex(); if ($shortcode !== '') { $new_shortcode = rawurldecode(base64_decode(strip_tags($shortcode))); } preg_match_all("/" . $pattern . "/", $new_shortcode, $matches); $shortcode_str = str_replace('"', '', str_replace(" ", "&", trim($matches[3][0]))); $short_atts = parse_str($shortcode_str); //explode("&",$shortcode_str); if (isset($matches[2][0])) { $display_type = $matches[2][0]; } else { $display_type = ''; } if (!isset($columns)) { $columns = '4'; } if (isset($per_page)) { $post_count = $per_page; } if (isset($number)) { $post_count = $number; } if (!isset($order)) { $order = 'ASC'; } if (!isset($orderby)) { $orderby = 'date'; } if (!isset($category)) { $category = ''; } if (!isset($ids)) { $ids = ''; } if ($ids) { $ids = explode(',', $ids); $ids = array_map('trim', $ids); } if ($columns == "2") { $columns = 6; } elseif ($columns == "3") { $columns = 4; } elseif ($columns == "4") { $columns = 3; } $meta_query = ''; if ($display_type == "recent_products") { $meta_query = WC()->query->get_meta_query(); } if ($display_type == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } if ($display_type == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $post_count, 'orderby' => $orderby, 'order' => $order, 'meta_query' => $meta_query); if ($display_type == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } if ($display_type == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } if ($display_type == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } if ($display_type == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN')); } $query = new WP_Query($args); $output .= '<ul class="wcmp-product-list wcmp-img-' . $img_position . ' ' . $order . '">'; if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $product_id = get_the_ID(); $post = get_post($product_id); $product_title = get_the_title(); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $rating = $product->get_rating_html(); $product_var = new WC_Product_Variable($product_id); $available_variations = $product_var->get_available_variations(); $output .= '<li>'; $output .= '<a href="' . get_permalink($product_id) . '">'; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), 'full'); $output .= '<img style="' . $style . '" src="' . $product_img[0] . '"/>'; $output .= '<span style="' . $title_style . '">' . $product_title . '</span>'; $output .= '</a>'; if ($display_type == "top_rated_products") { $output .= '<div style="' . $rating_style . '">' . $rating . '</div>'; } $output .= '<span class="amount" style="' . $pricing_style . '">' . $price . '</span>'; $output .= '</li>'; } } $output .= "\n" . '</ul>'; $output .= "\n" . '</div>'; if ($display_type == "top_rated_products") { remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); } wp_reset_postdata(); return $output; }
public function rewrite_shop_page() { global $is_shop; $woocommerce_db_version = get_option( 'woocommerce_db_version', null ); //Check rewrite this for shop page if ( !$is_shop || get_option('psad_shop_page_enable') != 'yes' ) return; //Start Shop global $woocommerce, $wp_query, $wp_rewrite; $enable_product_showing_count = get_option('psad_shop_enable_product_showing_count'); $product_ids_on_sale = ( ( version_compare( $woocommerce_db_version, '2.1', '<' ) ) ? woocommerce_get_product_ids_on_sale() : wc_get_product_ids_on_sale() ); $product_ids_on_sale[] = 0; $global_psad_shop_product_per_page = get_option('psad_shop_product_per_page', 0); $global_psad_shop_product_show_type = get_option('psad_shop_product_show_type', ''); $global_display_type = get_option('woocommerce_category_archive_display', ''); $term = get_queried_object(); $parent_id = empty( $term->term_id ) ? 0 : $term->term_id; $page = 1; if ( get_query_var( 'paged' ) ) $page = get_query_var( 'paged' ); $psad_shop_category_per_page = get_option('psad_shop_category_per_page', 0); if ( $psad_shop_category_per_page <= 0 ) $psad_shop_category_per_page = 3; $args = array( 'parent' => $parent_id, 'child_of' => $parent_id, 'menu_order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 1, 'taxonomy' => 'product_cat', 'pad_counts' => 1 ); $product_categories = get_categories( $args ); $numOfItems = $psad_shop_category_per_page; $to = $page * $numOfItems; $current = $to - $numOfItems; $total = sizeof($product_categories); $orderby = 'menu_order'; $order = 'ASC'; if ($to > count ($product_categories) ) $to = count($product_categories); $psad_es_category_item_bt_type = get_option( 'psad_es_category_item_bt_type' ); $psad_es_category_item_bt_text = esc_attr( stripslashes( get_option( 'psad_es_category_item_link_text', '' ) ) ); $psad_es_category_item_bt_position = get_option('psad_es_category_item_bt_position', 'bottom'); $class = 'click_more_link'; if ( $psad_es_category_item_bt_type == 'button' ) { $class = 'click_more_button'; $psad_es_category_item_bt_text = esc_attr( stripslashes( get_option( 'psad_es_category_item_bt_text', '' ) ) ); } if ( trim( $psad_es_category_item_bt_text ) == '' ) { $psad_es_category_item_bt_text = __('See more...', 'wc_psad'); } echo '<div style="clear:both;"></div>'; echo '<div class="pbc_container">'; echo '<div style="clear:both;"></div>'; echo '<div class="pbc_content">'; if ( $product_categories ) { $product_categories = array_values( $product_categories ); for ( $i = $current ; $i < $to ; ++$i ) { $category = $product_categories[$i]; $psad_shop_product_per_page = get_woocommerce_term_meta( $category->term_id, 'psad_shop_product_per_page', true ); if (!$psad_shop_product_per_page || $psad_shop_product_per_page <= 0) $psad_shop_product_per_page = $global_psad_shop_product_per_page; if ( $psad_shop_product_per_page <= 0 ) $psad_shop_product_per_page = 3; $psad_shop_product_show_type = get_woocommerce_term_meta( $category->term_id, 'psad_shop_product_show_type', true ); if (!$psad_shop_product_show_type || $psad_shop_product_show_type == '') $psad_shop_product_show_type = $global_psad_shop_product_show_type; $display_type = get_woocommerce_term_meta( $category->term_id, 'display_type', true ); if (!$display_type || $display_type == '') $display_type = $global_display_type; if ($psad_shop_product_show_type == 'none') { } elseif ($psad_shop_product_show_type == 'recent') { } elseif ($psad_shop_product_show_type == 'onsale') { $wp_query->query_vars['post__in'] = $product_ids_on_sale; } elseif ($psad_shop_product_show_type == 'featured') { $wp_query->query_vars['no_found_rows'] = 1; $wp_query->query_vars['post_status'] = 'publish'; $wp_query->query_vars['post_type'] = 'product'; if ( version_compare( $woocommerce_db_version, '2.1', '>' ) ) $wp_query->query_vars['meta_query'] = WC()->query->get_meta_query(); else $wp_query->query_vars['meta_query'] = $woocommerce->query->get_meta_query(); $wp_query->query_vars['meta_query'][] = array( 'key' => '_featured', 'value' => 'yes' ); } $product_args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $psad_shop_product_per_page, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN' ) ), 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'terms' => $category->slug , 'include_children' => false , 'field' => 'slug', 'operator' => 'IN' ) ) ); $ogrinal_product_args = $product_args; if ( $psad_shop_product_show_type == 'onsale' ) { $product_args['orderby'] = 'meta_value_num'; $product_args['order'] = 'DESC'; $product_args['meta_key'] = '_psad_onsale_order'; } elseif ( $psad_shop_product_show_type == 'featured' ) { $product_args['orderby'] = 'meta_value_num'; $product_args['order'] = 'DESC'; $product_args['meta_key'] = '_psad_featured_order'; } $products = query_posts( $product_args ); $psad_shop_drill_down = get_option('psad_shop_drill_down', 'yes'); $have_products = false; if ( have_posts() ) { $have_products = true; } elseif ( $psad_shop_drill_down == 'yes' ) { $product_args['tax_query'] = array( array( 'taxonomy' => 'product_cat', 'terms' => $category->slug , 'include_children' => true , 'field' => 'slug', 'operator' => 'IN' ) ); $products = query_posts( $product_args ); if ( have_posts() ) { $have_products = true; } } if ( $have_products ) { $total_posts = $wp_query->found_posts; $count_posts_get = count($products); $term_link_html = ''; if ( $category->parent > 0 ) { $my_term = get_term($category->parent,'product_cat'); $term_link = get_term_link( $my_term, 'product_cat' ); if ( is_wp_error( $term_link ) ) continue; $term_link_html = '<a href="'.$term_link.'">'. $my_term->name. '</a> / '; } $term_link_sub_html = get_term_link( $category->slug, 'product_cat' ); echo '<div id="products_categories_row_'.$category->term_id.'" class="products_categories_row">'; echo '<div class="custom_box custom_box_archive responsi_title">'; if ( $enable_product_showing_count == 'yes' || ( $count_posts_get < $total_posts && $psad_es_category_item_bt_position == 'top' ) ) { echo '<div class="product_categories_showing_count_container">'; if ( $enable_product_showing_count == 'yes' ) echo '<span class="product_categories_showing_count">'.__('Currently viewing', 'wc_psad'). ' 1 - ' .$count_posts_get.' '.__('of', 'wc_psad'). ' '. $total_posts .' '. __('products in this Category', 'wc_psad').'</span> '; if ( $count_posts_get < $total_posts && $psad_es_category_item_bt_position == 'top' ) echo '<span class="click_more_each_categories"><a class="categories_click '.$class.'" id="'.$category->term_id.'" href="'.$term_link_sub_html.'">'.$psad_es_category_item_bt_text.'</a></span>'; echo '</div>'; } echo "<div class='row'><div class='col-md-12'>"; echo '<h1 class="title pbc_title">'.$term_link_html.'<a href="'.$term_link_sub_html.'">' .$category->name.'</a></h1>'; if( trim($category->description) != '' ) { echo '<blockquote class="term-description"><p>'.$category->description.'</p></blockquote></div>'; } $thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true ); // get the image URL $image = wp_get_attachment_url( $thumbnail_id ); // print the IMG HTML //echo "<img style='margin-top: 20px;box-shadow: 6px 6px 17px #888888;' src='{$image}' alt=''/>"; $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => 5 ); $featured_query = new WP_Query( $args ); if ($featured_query->have_posts()) { while ($featured_query->have_posts()) { $featured_query->the_post(); $product = get_product( $featured_query->post->ID ); $term_id = wp_get_post_terms($featured_query->post->ID, 'product_cat', array("fields" => "ids")); if($term_id[0]==$category->term_id){ echo "<div class='col-md-12'><div class='row featured_cat_product'>"; echo "<div class='col-md-12'>"; echo "<label>".get_the_title($featured_query->post->ID)."</label></div><div class='col-md-12'>"; echo get_the_post_thumbnail( $featured_query->post->ID, 'full' ); echo '</div><div class="col-md-12">'; echo '<div class="col-md-8"><span>'.substr($featured_query->post->post_excerpt, 0, 40).'...</span></div>'; echo '<div class="col-md-4"><a href="'.get_permalink($featured_query->post->ID).'">Buy</a></div>'; echo "</div>"; echo "</div></div>"; $term_id=null; break; } } } $term_id=null; echo '</div></div>'; woocommerce_product_loop_start(); while ( have_posts() ) : the_post(); if ( version_compare( $woocommerce_db_version, '2.1', '<' ) ) woocommerce_get_template( 'content-product.php' ); else wc_get_template( 'content-product.php' ); endwhile; woocommerce_product_loop_end(); if ( $psad_es_category_item_bt_position != 'top' ) { if ( $count_posts_get < $total_posts ) { echo '<div class="click_more_each_categories" style="width:100%;clear:both;"><a class="categories_click '.$class.'" id="'.$category->term_id.'" href="'.$term_link_sub_html.'">'.$psad_es_category_item_bt_text.'</a></div>'; } else { echo '<div class="click_more_each_categories" style="width:100%;clear:both;"><span class="categories_click">'.__('No more products to view in this category', 'wc_psad').'</span></div>'; } } echo '</div>'; echo '<div class="psad_seperator products_categories_row" style="clear:both;"></div>'; } } } echo '<div style="clear:both;"></div>'; $psad_endless_scroll_category_shop = get_option('psad_endless_scroll_category_shop'); $psad_endless_scroll_category_shop_tyle = get_option('psad_endless_scroll_category_shop_tyle'); $use_endless_scroll = false; $show_click_more = false; if( $is_shop && $psad_endless_scroll_category_shop == 'yes'){ $use_endless_scroll = true; if( $psad_endless_scroll_category_shop_tyle == 'click'){ $show_click_more = true; } } if ( ceil($total / $numOfItems) > 1 ){ echo '<nav class="pagination woo-pagination woocommerce-pagination pbc_pagination">'; // fixed for 4.1.2 $defaults = array( 'base' => esc_url( add_query_arg( 'paged', '%#%' ) ), 'format' => '', 'total' => ceil($total / $numOfItems), 'current' => $page, 'prev_text' => '←', 'next_text' => '→', 'type' => 'list', 'end_size' => 3, 'mid_size' => 3 ); if( $wp_rewrite->using_permalinks() && ! is_search() ) $defaults['base'] = user_trailingslashit( trailingslashit( str_replace( 'page/'.$page , '' , esc_url( add_query_arg( array( 'paged' => false, 'orderby' => false ) ) ) ) ) . 'page/%#%' ); echo paginate_links( $defaults ); echo '</nav>'; } echo '</div><!-- pbc_content -->'; echo '<div style="clear:both;"></div>'; if ($use_endless_scroll) { $this->psad_endless_scroll_shop($show_click_more); } if ( $use_endless_scroll && $show_click_more ) { if ( ceil($total / $numOfItems) > 1 ) { $psad_es_shop_bt_type = get_option( 'psad_es_shop_bt_type' ); $psad_es_shop_bt_text = esc_attr( stripslashes( get_option( 'psad_es_shop_link_text', '' ) ) ); $class = 'click_more_link'; if ( $psad_es_shop_bt_type == 'button' ) { $class = 'click_more_button'; $psad_es_shop_bt_text = esc_attr( stripslashes( get_option( 'psad_es_shop_bt_text', '' ) ) ); } if ( trim( $psad_es_shop_bt_text ) == '' ) { $psad_es_shop_bt_text = __('Click More Categories', 'wc_psad'); } echo '<div class="pbc_content_click_more custom_box endless_click_shop"><a href="#"><a class="categories_click '.$class.'" href="#">'.$psad_es_shop_bt_text.'</a></div>'; } } echo '<div style="clear:both;"></div>'; echo '</div><!-- pbc_container -->'; echo '<div style="clear:both;"></div>'; wp_reset_postdata(); //End Shop }