/** * Renders item-bar of products in the loop * * @global WC_Product $product */ function dokan_product_loop_price() { global $product; ?> <span class="item-bar"> <?php woocommerce_template_loop_price(); ?> <span class="item-button"> <?php woocommerce_template_loop_add_to_cart(); ?> <?php if (function_exists('dokan_add_to_wishlist_link')) { dokan_add_to_wishlist_link(); } ?> </span> </span> <?php }
/** * Product loop desc */ function show_desc() { echo '<div class="product-item__desc">'; echo woocommerce_template_loop_product_title(); echo woocommerce_template_loop_price(); echo '</div>'; }
function waxom_woocommerce_product_details() { echo '<div class="vntd-product-excerpt">'; echo waxom_excerpt(20, false); echo '</div>'; echo '<div class="vntd-product-details btn btn-style-default btn-dark btn-icon accent-hover-bg"><i class="fa fa-file-text-o"></i>' . esc_html__('View Details', 'waxom') . '</div>'; echo '<div class="vntd-product-price">'; woocommerce_template_loop_price(); echo '<div class="vntd-product-rating">'; woocommerce_template_loop_rating(); echo '</div>'; echo '</div>'; echo '</div>'; // End details }
function thb_loop_product_end() { global $post, $product; $size = sizeof(get_the_terms($post->ID, 'product_cat')); echo $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $size, 'woocommerce') . ' ', '</span>'); woocommerce_template_loop_rating(); echo '<div class="thb-add-to-cart-wrapper">'; woocommerce_template_loop_price(); woocommerce_template_loop_add_to_cart(); echo "</div>"; echo "</div>"; }
function dt_woocommerce_shop_overview_extra_div_close() { global $product; $link = apply_filters( 'out_of_stock_add_to_cart_url', get_permalink( $product->id ) ); ob_start(); woocommerce_template_loop_price(); $price = ob_get_clean(); ob_start(); woocommerce_template_loop_add_to_cart(); $add_to_cart = ob_get_clean(); if( !empty($add_to_cart) ) { $add_to_cart = str_replace(' class="',' class="small button ',$add_to_cart); } echo " <div class='product-details'>"; echo $price; echo " <div class='product-buttons'>"; echo $add_to_cart; if ( shortcode_exists( 'yith_wcwl_add_to_wishlist' ) ) echo do_shortcode('[yith_wcwl_add_to_wishlist]'); echo " </div>"; echo " </div>"; echo ' </div>'; echo '</div>'; }
/** * Function to add after shop loop item */ function grve_woo_after_shop_loop_item() { ?> <div class="grve-product-options"> <?php woocommerce_template_loop_rating(); ?> <?php woocommerce_template_loop_add_to_cart(); ?> </div> </div> <div class="grve-product-content"> <span class="grve-product-name"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></span> <span class="grve-product-price"><?php woocommerce_template_loop_price(); ?> </span> </div> </div> <?php }
protected function content($atts, $content = null) { $class_col = null; extract(shortcode_atts(array('num_cols' => '2', 'num_posts' => '12', 'products_type' => '1', 'slugs' => 'web-design,logo-design,illustration'), $atts)); // $width_class = ''; // $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $width_class, $this->settings['base'], $atts ); switch ($num_cols) { case '2': $class_col = 'two_col'; break; case '3': $class_col = 'three_col'; break; case '4': $class_col = 'four_col'; break; default: $class_col = 'four_col'; break; } $args = array('post_type' => 'product', 'posts_per_page' => $num_posts); if ($products_type == '2') { $args = array('post_type' => 'product', 'posts_per_page' => $num_posts, 'meta_query' => array('relation' => 'OR', array('key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'), array('key' => '_min_variation_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'))); } if ($products_type == '3') { $args = array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $num_posts); } if ($products_type == '4') { $cat_slugs = explode(',', $slugs); $args = array('posts_per_page' => $num_posts, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $cat_slugs)), 'post_type' => 'product'); } ob_start(); ?> <div class="framed_wrapper_products"> <?php $products_loop = new WP_Query($args); if ($products_loop->have_posts()) { while ($products_loop->have_posts()) { $products_loop->the_post(); global $product, $post; $cat_count = sizeof(get_the_terms($post->ID, 'product_cat')); $attachment_id = $product->get_gallery_attachment_ids(); ?> <div class="framed_woo_product <?php echo esc_attr($class_col); ?> "> <div class="framed_img"> <a href="<?php the_permalink(); ?> "> <?php /** * woocommerce_before_shop_loop_item_title hook * * @hooked woocommerce_show_product_loop_sale_flash - 10 * @hooked woocommerce_template_loop_product_thumbnail - 10 */ do_action('woocommerce_before_shop_loop_item_title'); ?> </a> </div> <div class="framed_wrap_content"> <div> <?php echo apply_filters('woocommerce_loop_add_to_cart_link', sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" data-quantity="%s" class="button %s product_type_%s">%s</a>', esc_url($product->add_to_cart_url()), esc_attr($product->id), esc_attr($product->get_sku()), esc_attr(isset($quantity) ? $quantity : 1), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', esc_attr($product->product_type), esc_html($product->add_to_cart_text())), $product); ?> <a href="<?php the_permalink(); ?> "><?php _e('View More', THEME_NAME); ?> </a> </div> <div class="framed_content"> <div> <h3><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> <p><?php echo apply_filters('the_content', $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>')); ?> </p> </div> <div> <?php woocommerce_template_loop_price(); ?> </div> </div> </div> </div> <?php } } ?> </div> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title_popular']) ? __('Hot Products', 'wpdance') : $instance['title_popular']); $num_popular = empty($instance['num_popular']) ? 5 : absint($instance['num_popular']); $post_type = "product"; $thumbnail_width = 60; $thumbnail_height = 60; $output = $before_widget; if ($title) { $output .= $before_title . $title . $after_title; } echo $output; wp_reset_query(); $popular = new wp_query(array('post_type' => 'product', 'posts_per_page' => $num_popular, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'order' => 'DESC')); global $post, $product; ?> <?php if ($popular->post_count > 0) { $i = 0; $id_widget = 'hot_product-' . rand(0, 1000) . time(); ?> <ul class="popular-post-list<?php echo $id_widget; ?> "> <?php while ($popular->have_posts()) { $popular->the_post(); ?> <li> <div class="wd_hot_product_wrapper"> <div class="image image-style"> <a class="thumbnail" href="<?php echo get_permalink($post->ID); ?> "> <?php if (has_post_thumbnail()) { the_post_thumbnail('wd_hot_product', array('title' => esc_attr(get_the_title()), 'alt' => esc_attr(get_the_title()))); } ?> </a> <span class="shadow"></span> </div><!-- .image --> <?php $product = get_product($popular->post); ?> <div class="detail"> <p class="hot_pr_sku"><?php echo $product->get_sku(); ?> </p> <p class="title"><a href="<?php echo get_permalink($post->ID); ?> "><?php echo esc_attr(get_the_title($post->ID)); ?> </a></p> <?php //the_excerpt(); ?> <?php woocommerce_template_loop_price(); ?> </div> </div> </li> <?php } ?> </ul> <?php echo '<div class="clearfix"></div>'; echo '<div class="wd_hot_control"><a class="prev" title="prev" id="wd_hot_product_prev_' . $id_widget . '" href="#"><</a>'; echo '<a class="next" title="next" id="wd_hot_product_next_' . $id_widget . '" href="#" >></a> </div>'; } ?> <script type="text/javascript" language="javascript"> //<![CDATA[ jQuery(document).ready(function() { var li_widget = jQuery('.popular-post-list<?php echo $id_widget; ?> ').parent().parent('li'); var temp_class = ''; if(li_widget.hasClass('first')){ temp_class = '.first'; } _slider_datas = { responsive: true ,width : 240 ,height : 'auto' ,scroll : { items : 1, } ,debug : true ,auto : false ,swipe : { onMouse: true, onTouch: true } ,items : { width : 240 ,height : 'auto' ,visible : { min : 1 ,max : 1 } } // ,prev : '#wd_recent_posts_prev_<?php echo $id_widget; ?> ' // ,next : '#wd_recent_posts_next_<?php echo $id_widget; ?> ' }; jQuery('.widget_hot_product').each(function( i, value ) { if(jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').parent('.caroufredsel_wrapper').length > 0 ) return; jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').siblings('.wd_hot_control').addClass('control_' + i); jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').siblings('.wd_hot_control').addClass('control_' + i); jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').carouFredSel({ responsive: true ,width : 240 ,height : 'auto' ,scroll : { items : 1, } ,debug : true ,auto : false ,swipe : { onMouse: true, onTouch: true } ,items : { width : 240 ,height : 'auto' ,visible : { min : 1 ,max : 1 } } ,prev : '.control_' + i +' #wd_hot_product_prev_<?php echo $id_widget; ?> ' ,next : '.control_' + i+' #wd_hot_product_next_<?php echo $id_widget; ?> ' }); }); //window.setTimeout( function(){ // jQuery('.widget_hot_product' + temp_class +' .wd_recent_posts_<?php echo $id_widget; ?> ').carouFredSel(_slider_datas); //},2000); /* jQuery('window').bind('resize',jQuery.debounce( 250, function(){ _slider_config = get_layout_config(jQuery('.upsells.products').width(),_visible_items); _upsell_item_width = jQuery(window).width() < 600 ? 300 : 183; _slider_datas.items.width = _upsell_item_width; jQuery('#_upsell_ul_001').trigger('configuration ',["items.width", 300, true]); jQuery('#_upsell_ul_001').trigger('destroy',true); jQuery('#_upsell_ul_001').carouFredSel(_slider_datas); })); */ }); //]]> </script> <?php wp_reset_query(); ?> <?php echo $after_widget; }
function widget($args, $instance) { if (!ts_has_woocommerce()) { return; } extract($args); $title = apply_filters('widget_title', $instance['title']); $limit = $instance['limit'] != 0 ? absint($instance['limit']) : 8; $product_type = $instance['product_type']; $product_cats = $instance['product_cats']; $row = $instance['row'] != 0 ? absint($instance['row']) : 4; $show_thumbnail = empty($instance['show_thumbnail']) ? 0 : $instance['show_thumbnail']; $show_categories = empty($instance['show_categories']) ? 0 : $instance['show_categories']; $show_product_title = empty($instance['show_product_title']) ? 0 : $instance['show_product_title']; $show_price = empty($instance['show_price']) ? 0 : $instance['show_price']; $show_rating = empty($instance['show_rating']) ? 0 : $instance['show_rating']; $is_slider = empty($instance['is_slider']) ? 0 : $instance['is_slider']; $show_nav = empty($instance['show_nav']) ? 0 : $instance['show_nav']; $auto_play = empty($instance['auto_play']) ? 0 : $instance['auto_play']; if ($limit == $row) { $is_slider = false; } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $limit, 'orderby' => 'date', 'order' => 'desc', 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'))); switch ($product_type) { case 'sale': $args['meta_query'][] = array('key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'NUMERIC'); break; case 'featured': $args['meta_query'][] = array('key' => '_featured', 'value' => 'yes'); break; case 'best_selling': $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['order'] = 'desc'; break; case 'top_rated': add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); break; default: /* Recent */ $args['orderby'] = 'date'; $args['order'] = 'desc'; break; } if (is_array($product_cats) && count($product_cats) > 0) { $field_name = is_numeric($product_cats[0]) ? 'term_id' : 'slug'; $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $product_cats, 'field' => $field_name)); } global $post, $product, $smof_data; $lazy_load = isset($smof_data['ts_prod_lazy_load']) && $smof_data['ts_prod_lazy_load']; $placeholder_img_src = isset($smof_data['ts_prod_placeholder_img']) ? $smof_data['ts_prod_placeholder_img'] : wc_placeholder_img_src(); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $products = new WP_Query($args); if ($products->have_posts()) { $count = 0; $num_posts = $products->post_count; if ($num_posts <= $row) { $is_slider = false; } if (!$is_slider) { $row = $num_posts; } $extra_class = ''; $extra_class .= $is_slider ? 'ts-slider loading' : ''; $extra_class .= $is_slider && $show_nav ? ' has-navi' : ''; ?> <div class="ts-products-widget-wrapper woocommerce <?php echo esc_attr($extra_class); ?> " data-show_nav="<?php echo esc_attr($show_nav); ?> " data-auto_play="<?php echo esc_attr($auto_play); ?> "> <?php while ($products->have_posts()) { $products->the_post(); $product = wc_get_product($post->ID); ?> <?php if ($count % $row == 0) { ?> <div class="per-slide"> <ul class="product_list_widget"> <?php } ?> <li> <a class="ts-wg-thumbnail" href="<?php echo esc_url(get_permalink($product->id)); ?> " title="<?php echo esc_attr($product->get_title()); ?> "> <?php if ($show_thumbnail) { if (!$lazy_load) { echo $product->get_image(); } else { $image_size = 'shop_thumbnail'; $img_src = ''; $alt = ''; $dimensions = wc_get_image_size($image_size); if (has_post_thumbnail($product->id)) { $post_thumbnail_id = get_post_thumbnail_id($product->id); $image_obj = wp_get_attachment_image_src($post_thumbnail_id, $image_size, 0); if (isset($image_obj[0])) { $img_src = $image_obj[0]; } $alt = trim(strip_tags(get_post_meta($post_thumbnail_id, '_wp_attachment_image_alt', true))); } else { if (wc_placeholder_img_src()) { $img_src = wc_placeholder_img_src(); } } echo '<img src="' . esc_url($placeholder_img_src) . '" data-src="' . esc_url($img_src) . '" alt="' . esc_attr($alt) . '" class="attachment-shop_thumbnail wp-post-image ts-lazy-load" width="' . $dimensions['width'] . '" height="' . $dimensions['height'] . '" />'; } } ?> </a> <div class="ts-wg-meta"> <?php if ($show_categories) { ts_template_loop_categories(); } ?> <a href="<?php echo esc_url(get_permalink($product->id)); ?> " title="<?php echo esc_attr($product->get_title()); ?> "> <?php if ($show_product_title) { echo esc_html($product->get_title()); } ?> </a> <?php if ($show_price) { woocommerce_template_loop_price(); } ?> <?php if ($show_rating) { woocommerce_template_loop_rating(); } ?> </div> </li> <?php if ($count % $row == $row - 1 || $count == $num_posts - 1) { ?> </ul> </div> <?php } ?> <?php $count++; } ?> </div> <?php } echo $after_widget; if ($product_type == 'top_rated') { remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); } wp_reset_postdata(); }
function khore_woocommerce_before_shop_loop_item() { global $post; echo '<td class="title">'; do_action('woocommerce_before_shop_loop_item_title'); echo '<h3>' . get_the_title() . '</h3>'; do_action('woocommerce_after_shop_loop_item_title'); echo '</td>'; echo '<td class="description">'; echo '<span class="short-description">' . $post->post_excerpt . '</span>'; echo '</td>'; echo '<td class="price">'; woocommerce_template_loop_price(); echo '</td>'; echo '<td class="quantity">'; woocommerce_quantity_input(); echo '<input type="hidden" name="product_id" value="' . $post->ID . '" />'; echo '</td>'; }
function venedor_featured_products_slider() { $args = array('post_status' => 'publish', 'post_type' => 'product', 'ignore_sticky_posts' => 1, 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => 8, 'orderby' => 'date', 'order' => 'desc', 'product_cat' => get_query_var('product_cat')); $products = new WP_Query($args); global $venedor_product_slider; if ($products->have_posts()) { ?> <div class="product-featured-slider owl-carousel"> <?php while ($products->have_posts()) { $products->the_post(); if (!has_post_thumbnail()) { continue; } ?> <div class="container product-item product"><div class="row"> <div class="col-sm-5"> <?php venedor_woocommerce_image(); ?> </div> <div class="col-sm-7 product-details"><div class="inner"> <a href="<?php the_permalink(); ?> "> <h3 class="product-name"><?php the_title(); ?> </h3> </a> <div class="price-box"><?php echo woocommerce_template_loop_price(); ?> </div> <div class="product-desc"><?php echo venedor_excerpt(50, false); ?> </div> <?php global $product; if (!$product->is_in_stock()) { ?> <a href="<?php echo apply_filters('out_of_stock_add_to_cart_url', get_permalink($product->id)); ?> " class="button"><?php echo apply_filters('out_of_stock_add_to_cart_text', __('Read More', 'woocommerce')); ?> </a> <?php } else { $link = array('url' => '', 'label' => '', 'class' => ''); $handler = apply_filters('woocommerce_add_to_cart_handler', $product->product_type, $product); switch ($handler) { case "variable": $link['url'] = apply_filters('variable_add_to_cart_url', get_permalink($product->id)); $link['label'] = apply_filters('variable_add_to_cart_text', __('Select options', 'woocommerce')); break; case "grouped": $link['url'] = apply_filters('grouped_add_to_cart_url', get_permalink($product->id)); $link['label'] = apply_filters('grouped_add_to_cart_text', __('View options', 'venedor')); break; case "external": $link['url'] = apply_filters('external_add_to_cart_url', get_permalink($product->id)); $link['label'] = apply_filters('external_add_to_cart_text', __('Read More', 'woocommerce')); break; default: if ($product->is_purchasable()) { $link['url'] = apply_filters('add_to_cart_url', esc_url($product->add_to_cart_url())); $link['label'] = apply_filters('add_to_cart_text', __('Add to cart', 'woocommerce')); $link['class'] = apply_filters('add_to_cart_class', 'add_to_cart_button'); } else { $link['url'] = apply_filters('not_purchasable_url', get_permalink($product->id)); $link['label'] = apply_filters('not_purchasable_text', __('Read More', 'woocommerce')); } break; } echo apply_filters('woocommerce_loop_add_to_cart_link', sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="%s cart-links btn btn-lg product_type_%s">%s</a>', esc_url($link['url']), esc_attr($product->id), esc_attr($product->get_sku()), esc_attr($link['class']), esc_attr($product->product_type), esc_html($link['label'])), $product, $link); } ?> </div></div> </div></div> <?php } // end of the loop. ?> </div> <script type="text/javascript"> /* <![CDATA[ */ jQuery(function($) { var itemsCustom; $('.product-featured-slider').owlCarousel({ singleItem: true, navigation: false, pagination: false, transitionStyle : "fade", slideSpeed: 300 }); $('.product-featured-slider .product-image').addClass('effect2'); $('.product-featured-slider .product-image').append('<div class="btn btn-arrow prev"></div><div class="btn btn-arrow next"></div>'); $('.product-featured-slider .product-image .next').click(function() { $('.product-featured-slider').data('owl-carousel').next(); }); $('.product-featured-slider .product-image .prev').click(function() { $('.product-featured-slider').data('owl-carousel').prev(); }); }) /* ]]> */ </script> </div> <?php } wp_reset_postdata(); }
function dt_woocommerce_shop_overview_show_price() { $out = ""; global $product; ob_start(); woocommerce_template_loop_price(); $price = ob_get_clean(); $out .= "<div class='product-details'>"; $out .= '<h5><a href="' . get_permalink($product->id) . '">' . $product->post->post_title . '</a></h5>'; $out .= '<span class="product-price">' . $price . '</span>'; $out .= '</div>'; echo $out; }
function lab_wc_product_loop_item_info() { global $woocommerce, $product; $shop_catalog_layout = get_data('shop_catalog_layout'); $cart_url = $woocommerce->cart->get_cart_url(); $show_price = get_data('shop_product_price_listing'); $shop_product_category = get_data('shop_product_category_listing'); // Full + Transparent Background Layout Type if (in_array($shop_catalog_layout, array('full-bg', 'transparent-bg'))) { ?> <div class="item-info"> <h3 <?php if ($shop_catalog_layout == 'transparent-bg' && $shop_product_category == false) { ?> class="no-category-present"<?php } ?> > <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </h3> <?php if ($shop_product_category) { ?> <div class="product-category"> <?php echo $product->get_categories(); ?> </div> <?php } ?> <div class="product-bottom-details"> <?php if ($show_price) { woocommerce_template_loop_price(); } ?> <?php woocommerce_template_loop_add_to_cart(); ?> </div> </div> <?php // Centered – Distanced Background Layout Type } elseif (in_array($shop_catalog_layout, array('distanced-centered'))) { ?> <div class="item-info"> <div class="title-and-price"> <h3> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </h3> <?php if ($show_price) { woocommerce_template_loop_price(); } ?> </div> <?php woocommerce_template_loop_add_to_cart(); ?> </div> <?php } else { ?> <div class="item-info"> <div class="row custom-margin"> <div class="col-xs-<?php echo $show_price ? 9 : 12; ?> "> <h3> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </h3> <?php /*<a class="add-to-card-button" href="#">+ Add to cart</a>*/ ?> <?php woocommerce_template_loop_add_to_cart(); ?> </div> <?php if ($show_price) { ?> <div class="col-xs-3 product-price-col"> <?php woocommerce_template_loop_price(); ?> </div> <?php } ?> </div> </div> <div class="added-to-cart-button"> <a href="<?php echo $cart_url; ?> "><i class="icon icon-ecommerce-bag-check"></i></a> </div> <?php } }
protected function content($atts, $content = null) { $atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('list_product_megamenu', $atts) : $atts; $atts = shortcode_atts(array('title' => '', 'cat' => 0, 'number' => 4, 'types' => 'sale', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts); extract($atts); global $woocommerce_loop; $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'list_product_megamenu', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' ')); $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); ob_start(); $meta_query = WC()->query->get_meta_query(); $query = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $number, 'meta_query' => $meta_query); global $woocommerce_loop; $woocommerce_loop['columns'] = $number; if ($cat > 0) { $query['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $cat)); } if ($types == 'arrival') { $query['orderby'] = 'date'; $query['order'] = 'DESC'; } if ($types == 'sale') { $product_ids_on_sale = wc_get_product_ids_on_sale(); $query['meta_key'] = 'total_sales'; $query['orderby'] = 'meta_value_num'; $query['post__in'] = array_merge(array(0), $product_ids_on_sale); } if ($types == 'review') { add_filter('posts_clauses', array($this, 'order_by_rating_post_clauses')); } $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $query, $atts)); if ($types == 'review') { remove_filter('posts_clauses', array($this, 'order_by_rating_post_clauses')); } $bootstrapColumn = round(12 / $number); if ($products->have_posts()) { ?> <div class="mega-group <?php echo esc_attr($elementClass); ?> "> <?php if ($title != "") { ?> <h4 class="mega-group-header"><span><?php echo esc_attr($title); ?> </span></h4> <?php } ?> <div class="mega-products row"> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php global $product; $rating_count = $product->get_rating_count(); ?> <div class="col-sm-<?php echo esc_attr($bootstrapColumn); ?> mega-product"> <div class="product-avatar"> <a href="<?php the_permalink(); ?> "> <?php the_post_thumbnail('shop_catalog'); ?> </a> </div> <div class="product-name"> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </div> <div class="price-box"> <?php woocommerce_template_loop_price(); ?> </div> <?php echo edo_display_rating($rating_count); ?> </div> <?php } // end of the loop. ?> </div> </div> <?php } return ob_get_clean(); }
function dt_woocommerce_shop_overview_show_price() { global $product; ob_start(); woocommerce_template_loop_price(); $price = ob_get_clean(); echo $price; }
function dt_woocommerce_shop_overview_extra_div_close() { global $product; $link = apply_filters('out_of_stock_add_to_cart_url', get_permalink($product->id)); $out = ""; ob_start(); woocommerce_template_loop_price(); $price = ob_get_clean(); ob_start(); woocommerce_template_loop_add_to_cart(); $add_to_cart = ob_get_clean(); if (!empty($add_to_cart)) { $add_to_cart = str_replace(' class="', ' class="dt-sc-button ', $add_to_cart); } $out .= '<!-- Product Details -->'; $out .= "<div class='product-details'>"; $out .= $price; $out .= $add_to_cart; $out .= '</div><!-- Product Details -->'; $out .= '<div class="product-details-hover">'; $out .= "<h3><a href='{$link}'>" . $product->get_title() . '</a></h3>'; $rating = $product->get_rating_html(); //get rating $rating = !empty($rating) ? $rating : ""; $out .= $rating; $out .= $price; $out .= $add_to_cart; if (shortcode_exists('yith_wcwl_add_to_wishlist')) { $out .= do_shortcode('[yith_wcwl_add_to_wishlist]'); } $out .= '</div><!-- Product Details Hover -->'; $out .= "</div> </div> <!-- Product Wrapper End-->"; echo $out; }
?> " class="cbp-singlePageInline"><i class="icon-basket"></i></a> <a href="<?php the_permalink(); ?> " class="cbp-lightbox" data-title="<?php the_title(); ?> "><i class="icon-paperclip"></i></a> </p> </figcaption> </div> <div class="woo-title-price"> <h2><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <p><?php echo wp_kses_post(woocommerce_template_loop_price()); ?> </p> </div> </div> </li>
protected function content($atts, $content = null) { $class_col = null; extract(shortcode_atts(array('num_cols' => '2', 'num_posts' => '12', 'products_type' => '1', 'products_slider' => '', 'slugs' => 'web-design,logo-design,illustration', 'slides_show' => '1', 'slides_scroll' => '1'), $atts)); // $width_class = ''; // $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $width_class, $this->settings['base'], $atts ); switch ($num_cols) { case '2': $class_col = 'two_col'; break; case '3': $class_col = 'three_col'; break; case '4': $class_col = 'four_col'; break; default: $class_col = 'four_col'; break; } $args = array('post_type' => 'product', 'posts_per_page' => $num_posts); if ($products_type == '2') { $args = array('post_type' => 'product', 'posts_per_page' => $num_posts, 'meta_query' => array('relation' => 'OR', array('key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'), array('key' => '_min_variation_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'))); } if ($products_type == '3') { $args = array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $num_posts); } if ($products_type == '4') { $cat_slugs = explode(',', $slugs); $args = array('posts_per_page' => $num_posts, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $cat_slugs)), 'post_type' => 'product'); } ob_start(); ?> <div class="rated_woo_slider"> <?php if ($products_slider == 'true') { ?> <div class="custom_rate_nav"> <a href="#" data-scroll="prev"><i class="icon icon-arrow-67"></i> Prev</a> <a href="#" data-scroll="next">Next <i class="icon icon-arrow-68"></i></a> </div> <div class="slick_slider products_with_rate" data-slick='{"slidesToShow": <?php echo esc_attr($slides_show); ?> , "slidesToScroll": <?php echo esc_attr($slides_scroll); ?> , "autoplay": true, "autoplaySpeed": 3000, "arrows" : false}'> <?php } else { ?> <div class="products_with_rate"> <?php } ?> <?php $products_loop = new WP_Query($args); if ($products_loop->have_posts()) { while ($products_loop->have_posts()) { $products_loop->the_post(); global $product, $post; $attachment_id = $product->get_gallery_attachment_ids(); ?> <div class="rate_woo_holder <?php echo $products_slider != 'true' ? esc_attr($class_col) : ''; ?> "> <div class="product_img_holder"> <a href="<?php the_permalink(); ?> "> <?php if ($attachment_id) { $classes = array('hover_product_img'); $image = wp_get_attachment_image($attachment_id[0], apply_filters('single_product_small_thumbnail_size', 'shop_catalog')); $image_class = esc_attr(implode(' ', $classes)); $image_title = esc_attr(get_the_title($attachment_id[0])); echo apply_filters('woocommerce_single_product_image_thumbnail_html', sprintf('<div class="%s">%s</div>', $image_class, $image), $attachment_id[0], $post->ID, $image_class); } /** * woocommerce_before_shop_loop_item_title hook * * @hooked woocommerce_show_product_loop_sale_flash - 10 * @hooked woocommerce_template_loop_product_thumbnail - 10 */ do_action('woocommerce_before_shop_loop_item_title'); ?> </a> </div> <div class="product_pricing_holder"> <h3><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> </div> <div class="rate_price"> <div><?php woocommerce_template_loop_price(); ?> </div> <div><?php echo apply_filters('woocommerce_product_get_rating_html', $product->get_rating_html()); ?> </div> </div> </div> <?php } } ?> </div> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function tpvc_wc_product_featured_shortcode($atts) { if (!class_exists('woocommerce')) { return; } global $woocommerce_loop; extract(shortcode_atts(array('tpvc_wc_featured_title' => __('Featured Product', 'tokopress'), 'tpvc_wc_featured_title_color' => '', 'tpvc_wc_featured_title_bg' => '', 'tpvc_wc_featured_title_icon' => '', 'tpvc_wc_featured_title_icon_color' => '', 'tpvc_wc_featured_link' => __('see all', 'tokopress'), 'tpvc_wc_featured_link_color' => '', 'tpvc_wc_featured_number' => '6', 'tpvc_wc_featured_orderby' => 'date', 'tpvc_wc_featured_order' => 'desc', 'tpvc_wc_featured_hide_title' => '', 'tpvc_wc_featured_hide_prodprice' => '', 'tpvc_wc_featured_hide_prodtitle' => '', 'tpvc_wc_featured_hide_prodlink' => '', 'tpvc_wc_featured_hide_prodcart' => '', 'tpvc_wc_featured_hide_prodlink_text' => __('detail', 'tokopress'), 'tpvc_wc_featured_class' => ''), $atts)); $tpvc_wc_featured_columns = 1; $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $tpvc_wc_featured_number, 'orderby' => $tpvc_wc_featured_orderby, 'order' => $tpvc_wc_featured_order, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes'))); ob_start(); $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts)); $woocommerce_loop['columns'] = $tpvc_wc_featured_columns; if ($products->have_posts()) { ?> <div class="tpvc-featured-product woocommerce woocommerce-product-col-<?php echo $tpvc_wc_featured_columns; ?> <?php echo $tpvc_wc_featured_class; ?> "> <?php if ("hide" != $tpvc_wc_featured_hide_title) { ?> <?php if ($tpvc_wc_featured_link_color) { echo '<style>'; echo '.tpvc-featured-product.woocommerce .tpvc-title a.button.alt { color:' . $tpvc_wc_featured_link_color . '; box-shadow: ' . $tpvc_wc_featured_link_color . ' 0 0px 0px 2px inset; }'; echo '.tpvc-featured-product.woocommerce .tpvc-title a.button.alt:hover { color: #fff; box-shadow: ' . $tpvc_wc_featured_link_color . ' 0 0px 0px 40px inset; }'; echo '</style>'; } ?> <div class="tpvc-title" <?php if ("" != $tpvc_wc_featured_title_bg) { echo 'style="background-color:' . $tpvc_wc_featured_title_bg . '"'; } ?> > <h2 <?php if ("" != $tpvc_wc_featured_title_color) { echo 'style="color:' . $tpvc_wc_featured_title_color . '"'; } ?> > <?php if ("" != $tpvc_wc_featured_title_icon) { echo '<i class="' . tpvc_icon($tpvc_wc_featured_title_icon) . '" ' . ($tpvc_wc_featured_title_icon_color ? 'style="color:' . $tpvc_wc_featured_title_icon_color . '"' : '') . '></i>'; } ?> <?php echo $tpvc_wc_featured_title; ?> </h2> <a href="<?php echo get_permalink(wc_get_page_id('shop')); ?> " class="button alt"> <?php if (!$tpvc_wc_featured_link) { $tpvc_wc_featured_link = __('see all', 'tokopress'); } echo $tpvc_wc_featured_link; ?> </a> </div> <?php } ?> <ul class="products owl-carousel"> <?php while ($products->have_posts()) { $products->the_post(); ?> <li <?php post_class(); ?> > <div class="featured-top"> <?php the_post_thumbnail('custom-woo-thumbnail'); ?> </div> <?php if ("yes" != $tpvc_wc_featured_hide_prodprice || "yes" != $tpvc_wc_featured_hide_prodtitle || "yes" != $tpvc_wc_featured_hide_prodlink || "yes" != $tpvc_wc_featured_hide_prodcart) { ?> <div class="featured-bottom"> <?php if ("yes" != $tpvc_wc_featured_hide_prodprice) { ?> <div class="featured-price"> <?php woocommerce_template_loop_price(); ?> </div> <?php } ?> <?php if ("yes" != $tpvc_wc_featured_hide_prodlink || "yes" != $tpvc_wc_featured_hide_prodcart) { ?> <div class="featured-action"> <?php if ("yes" != $tpvc_wc_featured_hide_prodlink) { ?> <a href="<?php echo get_permalink(); ?> " class="button detail_button_loop"> <?php if (!$tpvc_wc_featured_hide_prodlink_text) { $tpvc_wc_featured_hide_prodlink_text = __('detail', 'tokopress'); } echo $tpvc_wc_featured_hide_prodlink_text; ?> </a> <?php } ?> <?php if ("yes" != $tpvc_wc_featured_hide_prodcart) { ?> <?php woocommerce_template_loop_add_to_cart(); ?> <?php } ?> </div> <?php } ?> <?php if ("yes" != $tpvc_wc_featured_hide_prodtitle) { ?> <div class="featured-title"> <h3><a href="<?php echo get_permalink(); ?> "><?php the_title(); ?> </a></h3> </div> <?php } ?> </div> <?php } ?> </li> <?php } ?> </ul> </div> <?php } wp_reset_postdata(); $js_code = '$(\'.tpvc-featured-product ul.owl-carousel\').owlCarousel({ items : 1, loop: true, nav : true, stopOnHover : true, navText : [\'<i class="fa fa-chevron-left"></i>\', \'<i class="fa fa-chevron-right"></i>\'], lazyLoad: true, autoplay: true, dots: false });'; wc_enqueue_js($js_code); return ob_get_clean(); }
protected function content($atts, $content = null) { extract(shortcode_atts(array("slides_show" => "1", "slides_scroll" => "1", "title" => "Main Title", "subtitle" => "Some Awesome Subtitle"), $atts)); ob_start(); ?> <div class="selective_products_wraper"> <div class="main_selective_wrap"> <div class="match-me custom_box_nav"> <div class="text_wraper"> <?php if (!empty($subtitle)) { ?> <span><?php echo esc_html($subtitle); ?> </span> <?php } ?> <?php if (!empty($title)) { ?> <h1><?php echo esc_html($title); ?> </h1> <?php } ?> <div class="custom_selective_nav"> <a href="#" data-scroll="prev"><i class="icon icon-arrow-67"></i> <?php _e('Prev', THEME_NAME); ?> </a> <a href="#" data-scroll="next"><?php _e('Next', THEME_NAME); ?> <i class="icon icon-arrow-68"></i></a> </div> </div> </div> <div class="match-me"> <div class="slick_slider selected_products" data-slick='{"slidesToShow": <?php echo esc_attr($slides_show); ?> , "arrows" : false, "slidesToScroll": <?php echo esc_attr($slides_scroll); ?> , "autoplay": true, "autoplaySpeed": 3000, "responsive": [{ "breakpoint": 990, "settings": { "slidesToShow": 3, "slidesToScroll" : 1, "arrows" : false }}, { "breakpoint": 640, "settings": { "slidesToShow": 1, "slidesToScroll" : 1, "arrows" : false }}]}'> <?php $args = array('post_type' => 'product', 'posts_per_page' => -1); $loop = new WP_Query($args); if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); global $post, $product; ?> <div> <div class="product_img_holder"> <a href="<?php the_permalink(); ?> "> <div><span><?php _e('View More', THEME_NAME); ?> </span></div> <?php /** * woocommerce_before_shop_loop_item_title hook * * @hooked woocommerce_show_product_loop_sale_flash - 10 * @hooked woocommerce_template_loop_product_thumbnail - 10 */ do_action('woocommerce_before_shop_loop_item_title'); ?> </a> </div> <div class="product_pricing_holder"> <h3><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> <div class="star-rating-wraper"><?php echo apply_filters('woocommerce_product_get_rating_html', $product->get_rating_html()); ?> </div> <div><?php woocommerce_template_loop_price(); ?> </div> </div> </div> <?php } } ?> </div> </div> </div> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function vc_category_container_func($atts, $content = null) { extract(shortcode_atts(array('slug' => '', 'column' => '', 'thumbnail' => '', 'list_style' => ''), $atts)); if (empty($list_style)) { $list_style = 'style_1'; } if (empty($thumbnail)) { $thumbnail = 'theme-size-1x1'; } if (empty($column)) { $column = '3'; } $content = wpb_js_remove_wpautop($content); // fix unclosed/unwanted paragraph tags in $content #$cat = get_category_by_slug(); $cat = get_term_by('slug', $slug, 'product_cat'); $thumbnail_id = get_woocommerce_term_meta($cat->term_id, 'thumbnail_id', true); $image = wp_get_attachment_image_src($thumbnail_id, $thumbnail); $items = $column; ob_start(); ?> <div class="lpd-category-container"> <table> <tbody> <tr> <td class="cc-meta-column"> <div class="ribbon cc-ribbon"> <span class="ribbon-content"> <span class="content-ribbon"><h3><?php echo esc_html($cat->name); ?> </h3></span> </span> </div> <?php $title_li = ''; if ($list_style == 'style_2') { $title_li = " "; } $cc_cat_list = array('child_of' => $cat->term_id, 'depth' => 0, 'title_li' => $title_li, 'taxonomy' => 'product_cat'); ?> <?php if ($list_style == 'style_2') { echo '<ul class="cc-cat-list cc-cat-list-style2">'; } else { echo '<ul class="cc-cat-list">'; } wp_list_categories($cc_cat_list); echo '</ul>'; ?> <?php if ($content) { ?> <div class="cc-description"> <?php echo $content; ?> </div> <?php } ?> <a href="<?php echo esc_url(get_term_link($slug, 'product_cat')); ?> " class="btn btn-warning"><?php _e("View More", GETTEXT_DOMAIN); ?> </a> </td> <td class="cc-content-column"> <?php if ($image) { ?> <img class="cc-img" src="<?php echo esc_url($image[0]); ?> " alt="" /> <?php } ?> <div class="cc-products"> <ul class="cc-col cc-col-<?php echo esc_attr($column); ?> clearfix"> <?php $query = new WP_Query(); ?> <?php $query->query('post_type=product&product_cat=' . $slug . '&posts_per_page=' . $items . ''); ?> <?php if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <li> <div class="cc-product-item"> <a href="<?php the_permalink(); ?> " class="cc-product-thumbnail"> <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) { ?> <img src="<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'theme-size-1x1'); echo esc_url($image[0]); ?> " alt='<?php the_title(); ?> '> <?php } else { ?> <img src="<?php echo esc_url(get_template_directory_uri()) . '/assets/img/add-featured-image.png'; ?> " alt='<?php the_title(); ?> '> <?php } ?> </a> <div class="cc-price"><?php woocommerce_template_loop_price(); ?> </div> </div> </li> <?php } } wp_reset_query(); ?> </ul> </div> </td> </tr> </tbody> </table> </div> <?php return ob_get_clean(); }
public function widget($args, $instance) { echo apply_filters('edo_wg_before_widget', $args['before_widget']); $title = isset($instance['title']) ? esc_attr($instance['title']) : 'Specials'; $orderby = isset($instance['orderby']) ? $instance['orderby'] : 'date'; $order = isset($instance['order']) ? $instance['order'] : 'desc'; $posts_per_page = isset($instance['posts_per_page']) ? $instance['posts_per_page'] : '3'; $meta_query = WC()->query->get_meta_query(); $params = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $posts_per_page, 'meta_query' => $meta_query, 'suppress_filter' => true, 'orderby' => $orderby, 'order' => $order); if ($title) { echo apply_filters('edo_wg_after_title', $args['before_title']); echo esc_html($title); echo apply_filters('edo_wg_after_title', $args['after_title']); } $product = new WP_Query($params); ?> <!-- SPECIAL --> <div class="block-specials"> <?php if ($product->have_posts()) { ?> <?php while ($product->have_posts()) { $product->the_post(); ?> <div class="product"> <div class="image"> <a href="<?php the_permalink(); ?> "> <?php the_post_thumbnail('shop_thumbnail'); ?> </a> </div> <div class="product-name"> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </div> <?php woocommerce_template_loop_price(); ?> </div> <?php } ?> <?php } wp_reset_query(); wp_reset_postdata(); $shop_page_url = get_permalink(woocommerce_get_page_id('shop')); ?> <a href="<?php echo esc_url($shop_page_url); ?> " class="button-radius"><?php esc_html_e('All Products', 'edo'); ?> <span class="icon"></span></a> </div> <!-- ./SPECIAL --> <?php echo apply_filters('edo_wg_after_widget', $args['after_widget']); }
protected function content($atts, $content = null) { $class_col = null; extract(shortcode_atts(array('num_cols' => '2', 'num_posts' => '12', 'products_type' => '1', 'products_slider' => '', 'slugs' => 'web-design,logo-design,illustration', 'slides_show' => '1', 'slides_scroll' => '1'), $atts)); // $width_class = ''; // $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $width_class, $this->settings['base'], $atts ); switch ($num_cols) { case '2': $class_col = 'two_col'; break; case '3': $class_col = 'three_col'; break; case '4': $class_col = 'four_col'; break; default: $class_col = 'four_col'; break; } $args = array('post_type' => 'product', 'posts_per_page' => $num_posts); if ($products_type == '2') { $args = array('post_type' => 'product', 'posts_per_page' => $num_posts, 'meta_query' => array('relation' => 'OR', array('key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'), array('key' => '_min_variation_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'))); } if ($products_type == '3') { $args = array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $num_posts); } if ($products_type == '4') { $cat_slugs = explode(',', $slugs); $args = array('posts_per_page' => $num_posts, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $cat_slugs)), 'post_type' => 'product'); } ob_start(); ?> <?php if ($products_slider == 'true') { ?> <div class="slick_slider product_container_custom" data-slick='{"arrows": false, "slidesToShow": <?php echo esc_attr($slides_show); ?> , "slidesToScroll": <?php echo esc_attr($slides_scroll); ?> , "autoplay": true, "autoplaySpeed": 3000, "responsive": [{ "breakpoint": 900, "settings": { "slidesToShow": 2, "slidesToScroll" : 1, "arrows" : false }}, { "breakpoint": 580, "settings": { "slidesToShow": 1, "slidesToScroll" : 1, "arrows" : false }}]}'> <?php } else { ?> <div class="product_container_custom"> <?php } ?> <?php $products_loop = new WP_Query($args); if ($products_loop->have_posts()) { while ($products_loop->have_posts()) { $products_loop->the_post(); global $product, $post; $cat_count = sizeof(get_the_terms($post->ID, 'product_cat')); ?> <div class="<?php echo $products_slider != 'true' ? esc_attr($class_col) : ''; ?> "> <div class="product_img_holder"> <a href="<?php the_permalink(); ?> "> <?php /** * woocommerce_before_shop_loop_item_title hook * * @hooked woocommerce_show_product_loop_sale_flash - 10 * @hooked woocommerce_template_loop_product_thumbnail - 10 */ do_action('woocommerce_before_shop_loop_item_title'); ?> </a> </div> <div class="product_pricing_holder"> <h3><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> <?php woocommerce_template_loop_price(); ?> </div> <div class="product_meta_holder"> <?php echo apply_filters('the_content', $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>')); ?> </div> </div> <?php } } ?> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function wd_hot_product($atts, $content = null) { extract(shortcode_atts(array('title' => '', 'number' => '4'), $atts)); $post_type = "product"; $thumbnail_width = 60; $thumbnail_height = 60; wp_reset_query(); $popular = new wp_query(array('post_type' => 'product', 'posts_per_page' => $number, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'order' => 'DESC')); global $post, $product; ?> <?php if ($popular->post_count > 0) { $i = 0; $id_widget = 'hot_product-' . rand(0, 1000) . time(); $count = 1; ob_start(); ?> <div class="wd_hot_product wd_hot_loading"> <div class="wd_heading"> <h5>hot products</h5> <div class="wd_number_real"><span>1/<?php echo $popular->post_count; ?> </span></div> </div> <ul class="products popular-post-list<?php echo $id_widget; ?> "> <?php while ($popular->have_posts()) { $popular->the_post(); ?> <li class="post-<?php echo $post->ID; ?> product type-product status-publish henry"> <div class="wd_number"><span><?php echo $count; ?> /<?php echo $popular->post_count; ?> </span></div> <div class="wd_product_wrapper"> <div class="product_thumbnail_wrapper image image-style"> <a class="thumbnail" href="<?php echo get_permalink($post->ID); ?> "> <?php if (has_post_thumbnail()) { the_post_thumbnail('wd_hot_product', array('title' => esc_attr(get_the_title()), 'alt' => esc_attr(get_the_title()))); } ?> </a> <span class="shadow"></span> <?php global $wd_data; if (!isset($wd_data['wd_catelog_mod']) || isset($wd_data['wd_catelog_mod']) && $wd_data['wd_catelog_mod'] == 1) { ?> <div class='list_add_to_cart'> <?php woocommerce_template_loop_add_to_cart(); ?> </div> <?php } ?> </div><!-- .image --> <?php $product = get_product($popular->post); ?> <div class="product-meta-wrapper detail"> <p class="hot_pr_sku"><?php echo $product->get_sku(); ?> </p> <p class="title"><a href="<?php echo get_permalink($post->ID); ?> "><?php echo esc_attr(get_the_title($post->ID)); ?> </a></p> <?php //the_excerpt(); ?> <?php woocommerce_template_loop_price(); ?> </div> <input type='hidden' value='<?php echo $product->id; ?> ' class='hidden_product_id product_hidden_<?php echo $product->id; ?> '> </div> </li> <?php $count++; ?> <?php } ?> </ul> <?php echo '<div class="clearfix"></div>'; echo '<div class="wd_hot_control"><a class="prev" title="prev" id="wd_hot_product_prev_' . $id_widget . '" href="#"><</a>'; echo '<a class="next" title="next" id="wd_hot_product_next_' . $id_widget . '" href="#" >></a> </div>'; } ?> </div> <script type="text/javascript" language="javascript"> //<![CDATA[ jQuery(document).ready(function() { jQuery('.wd_hot_product').removeClass('wd_hot_loading'); var li_widget = jQuery('.popular-post-list<?php echo $id_widget; ?> ').parent().parent('li'); var temp_class = ''; if(li_widget.hasClass('first')){ temp_class = '.first'; } _slider_datas = { responsive: true ,width : 240 ,height : 'auto' ,scroll : { items : 1, } ,debug : true ,auto : false ,swipe : { onMouse: true, onTouch: true } ,items : { width : 240 ,height : 'auto' ,visible : { min : 1 ,max : 1 } } ,scroll : { items : 1 ,onAfter : function( data ) { var temp = jQuery('.wd_hot_product .wd_number').html(); jQuery('.wd_hot_product .wd_number_real').html(temp); } } }; jQuery('.wd_hot_product').each(function( i, value ) { if(jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').parent('.caroufredsel_wrapper').length > 0 ) return; jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').siblings('.wd_hot_control').addClass('control_' + i); jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').siblings('.wd_hot_control').addClass('control_' + i); _slider_datas.prev = '.control_' + i +' #wd_hot_product_prev_<?php echo $id_widget; ?> '; _slider_datas.next = '.control_' + i+' #wd_hot_product_next_<?php echo $id_widget; ?> '; jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').carouFredSel(_slider_datas); }); jQuery('window').bind('resize',jQuery.debounce( 250, function(){ jQuery('.wd_hot_product').each(function( i, value ) { jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').trigger('configuration ',["items.width", 300, true]); jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').trigger('destroy',true); jQuery(value).find('ul.popular-post-list<?php echo $id_widget; ?> ').carouFredSel(_slider_datas); }); })); }); //]]> </script> <?php $ret_html = ob_get_contents(); ob_end_clean(); ?> <?php wp_reset_query(); ?> <?php return $ret_html; }
* @hooked woocommerce_template_loop_product_thumbnail - 10 */ do_action('woocommerce_before_shop_loop_item_title'); ?> </a> </div> </div> <div class="product-meta col-md-8 "> <h4 class="name"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h4> <?php woocommerce_template_single_rating(); woocommerce_template_loop_price(); woocommerce_template_single_excerpt(); ?> <div class="button-groups"> <div class="button-item clearfix"> <?php do_action('woocommerce_after_shop_loop_item'); ?> </div> </div> </div> </div> </div> </div>
protected function content($atts, $content = null) { $class_col = null; extract(shortcode_atts(array('num_cols' => '1', 'num_posts' => '12', 'products_type' => '1', 'products_slider' => '', 'slugs' => 'web-design,logo-design,illustration', 'slides_show' => '1', 'slides_scroll' => '1'), $atts)); // $width_class = ''; // $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $width_class, $this->settings['base'], $atts ); switch ($num_cols) { case '2': $class_col = 'two_col'; break; case '3': $class_col = 'three_col'; break; case '4': $class_col = 'four_col'; break; default: $class_col = 'four_col'; break; } $args = array('post_type' => 'product', 'posts_per_page' => $num_posts); if ($products_type == '2') { $args = array('post_type' => 'product', 'posts_per_page' => $num_posts, 'meta_query' => array('relation' => 'OR', array('key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'), array('key' => '_min_variation_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'))); } if ($products_type == '3') { $args = array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $num_posts); } if ($products_type == '4') { $cat_slugs = explode(',', $slugs); $args = array('posts_per_page' => $num_posts, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $cat_slugs)), 'post_type' => 'product'); } ob_start(); ?> <?php if ($products_slider == 'true') { ?> <div class="slick_slider circled_custom_products" data-slick='{"slidesToShow": <?php echo esc_attr($slides_show); ?> , "slidesToScroll": <?php echo esc_attr($slides_scroll); ?> , "autoplay": true, "autoplaySpeed": 3000, "responsive": [{ "breakpoint": 1200, "settings": { "slidesToShow": 3, "slidesToScroll" : 1, "arrows" : false }}, { "breakpoint": 640, "settings": { "slidesToShow": 1, "arrows" : false, "slidesToScroll" : 1, "arrows" : false }}]}'> <?php } else { ?> <div class="circled_custom_products"> <?php } ?> <?php $products_loop = new WP_Query($args); if ($products_loop->have_posts()) { while ($products_loop->have_posts()) { $products_loop->the_post(); global $product, $post; ?> <div class="<?php echo $products_slider != 'true' ? esc_attr($class_col) : ''; ?> "> <div class="product_img_holder"> <?php $price = null; if ($product->is_on_sale() && $product->product_type == 'variable') { ?> <span class="bubble"> <?php $available_variations = $product->get_available_variations(); $maximumper = 0; for ($i = 0; $i < count($available_variations); ++$i) { $variation_id = $available_variations[$i]['variation_id']; $variable_product1 = new WC_Product_Variation($variation_id); $regular_price = $variable_product1->regular_price; $sales_price = $variable_product1->sale_price; $percentage = round(($regular_price - $sales_price) / $regular_price * 100, 1); if ($percentage > $maximumper) { $maximumper = $percentage; } } echo esc_html($price) . sprintf(__('%s', THEME_NAME), $maximumper . '%'); ?> </span><!-- end callout --> <?php } elseif ($product->is_on_sale() && $product->product_type == 'simple') { ?> <span class="bubble"> <?php $percentage = round(($product->regular_price - $product->sale_price) / $product->regular_price * 100); echo esc_html($price) . sprintf(__('%s', THEME_NAME), $percentage . '%'); ?> </span><!-- end bubble --> <?php } ?> <a href="<?php the_permalink(); ?> "> <span class="circled_icon_holder"><i class="icon icon-cross"></i></span> <?php woocommerce_template_loop_product_thumbnail(); ?> </a> </div> <div class="product_pricing_holder"> <h3><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> <?php woocommerce_template_loop_price(); ?> </div> </div> <?php } } ?> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }