public function mango_feature_product($atts) { $output = ""; extract(shortcode_atts(array('heading' => '', 'number_cat' => 3, 'product_select' => '', 'categories' => ''), $atts)); if (!taxonomy_exists("product_cat")) { return; } $output .= '<div class="widget">'; $output .= '<h4>' . esc_attr($heading) . '</h4>'; $output .= '<ul class="products-list">'; $query_arg = array('post_type' => 'product', 'posts_per_page' => $number_cat, 'product_cat' => $categories); if ($product_select == 'Featured') { $query_arg['meta_key'] = '_featured'; $query_arg['meta_value'] = 'yes'; } else { if ($product_select == 'best_selling') { $query_arg['post__in'] = mango_woocomerce_bestsellers(); } } $select_feature = new WP_Query($query_arg); if ($select_feature->have_posts()) { while ($select_feature->have_posts()) { global $product; $select_feature->the_post(); $category = get_term_by('name', $categories, 'product_cat'); $product = get_product($select_feature->post->ID); $output .= ' <li>'; $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($product->id)); if (has_post_thumbnail($product->id) && !post_password_required()) { $output .= ' <figure>'; $output .= ' <a href="' . get_the_permalink() . '">'; $output .= ' <img src="' . esc_url($img_src[0]) . '" alt="' . get_the_title() . '" class="product-image"></a>'; $output .= '</figure>'; } $output .= '<h5 class="product-title">'; $output .= '<a href="' . get_the_permalink() . '">' . get_the_title() . '</a>'; $output .= '</h5>'; $output .= '<div class="product-price-container">'; if ($product->get_regular_price() && $product->get_sale_price()) { $output .= '<span class="product-old-price">' . get_woocommerce_currency_symbol() . ' ' . $product->get_regular_price() . '</span>'; $output .= '<span class="product-price">' . get_woocommerce_currency_symbol() . ' ' . $product->get_sale_price() . '</span>'; } elseif ($product->get_regular_price()) { $output .= '<span class="product-price">' . get_woocommerce_currency_symbol() . ' ' . $product->get_regular_price() . '</span>'; } elseif ($product->get_sale_price()) { $output .= '<span class="product-price">' . get_woocommerce_currency_symbol() . ' ' . $product->get_sale_price() . '</span>'; } $output .= '</div><!-- End .product-price-container -->'; $output .= '</li>'; } } $output .= '</ul>'; $output .= '</div>'; return $output; }
function mango_woo_product($atts) { global $mango_settings; extract(shortcode_atts(array('product_style' => 'style2', 'textalign' => '', 'show_product' => '-1', 'product_cats' => '', 'post_per_column_style1' => ' fullwidth', 'per_column_desktop' => '3', 'selecttype' => '', 'per_column_tab' => '6', 'show_cat' => 'yes', 'show_rating' => 'yes', 'show_price' => 'yes'), $atts)); ob_start(); if ($product_style == 'style1') { ?> <div class="product-container<?php echo esc_attr($post_per_column_style1s); ?> "> <?php } elseif ($product_style == 'style2') { ?> <div class="row"> <?php } $args = array('post_type' => 'product', 'showposts' => $show_product, 'product_cat' => $product_cats); if ($selecttype == 'featured') { $args['meta_key'] = '_featured'; $args['meta_value'] = 'yes'; } else { if ($selecttype == 'selling') { $args['post__in'] = mango_woocomerce_bestsellers(); } } $argsd = query_posts($args); $post = new WP_Query($argsd); ?> <div class="owl-carousel home-newarrivals-carousel" data-items="<?php echo esc_attr($per_column_desktop); ?> " data-number-of-pro-cols="<?php if ($product_style == 'style2') { echo esc_attr($per_column_desktop); } elseif ($product_style == 'style1') { echo esc_attr($post_per_column_style1); } ?> "> <?php if (have_posts()) { while (have_posts()) { the_post(); global $product, $woocommerce; $product_cats = $product->get_categories(' | ', '', ''); $attachment_ids = $product->get_gallery_attachment_ids(); if ($product_style == 'style1') { ?> <div class="product"> <div class="product-top no-margin"> <figure> <a href="<?php echo get_the_permalink(); ?> " title="<?php echo get_the_title(); ?> "> <?php echo '<a href="' . get_the_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, 'product-thumbnail', array("class" => "product-image")) . '</a>'; ?> </a> </figure> </div><!-- End .product-top --> <div class="product-meta-box"> <?php if ($show_cat == 'yes') { ?> <div class="product-cats"><?php echo $product_cats; ?> </div><!-- End .product-cats --> <?php } ?> <h3 class="product-title"><a href="<?php echo get_the_permalink(); ?> " title="<?php echo get_the_title(); ?> "><?php echo get_the_title(); ?> </a></h3> <?php if ($show_rating == 'yes') { ?> <?php if ($rating_html = $product->get_rating_html()) { $rating = $product->get_average_rating(); $rating_html = $product->get_rating_html(); $count = 0; ?> <div class="product-ratings"> <?php for ($i = 0; $i < (int) $rating; $i++) { $count++; echo '<span class="star active"></span>'; } if ($rating - (int) $rating >= 0.5) { $count++; echo '<span class="star active-half"></span>'; } for ($i = $count; $i < 5; $i++) { $count++; echo '<span class="star"></span>'; } ?> <span class="rating-amount"> <?php $rev_count = $product->get_review_count(); echo $rev_count . " "; if ($rev_count == 0 || $rev_count > 1) { _e("Reviews", 'mango'); } elseif ($rev_count == 1) { _e("Review", 'mango'); } ?> </span> </div> <?php } ?> <?php } ?> <?php if ($show_price == 'yes') { ?> <?php wc_get_template_part("loop/price"); ?> <?php } ?> </div><!-- End .product-meta-box --> </div><!-- End .product --> <?php } elseif ($product_style == 'style2') { ?> <div class="product <?php echo esc_attr($textalign); ?> "> <?php global $mango_settings; ?> <div class="product-top"> <?php if ($mango_settings['mango_show_compare_button']) { if (in_array('yith-woocommerce-compare/init.php', apply_filters('active_plugins', get_option('active_plugins')))) { echo do_shortcode('[yith_compare_button]'); } } if ($mango_settings['mango_show_quick_button']) { ?> <div class="woocommerce product quick-button"> <a class="top-line-a right open-product btn btn-custom2 btn-xs" data-id="<?php echo the_ID(); ?> "><i class="fa fa-expand"></i> <span><?php _e('Quick View', 'mango'); ?> </span> </a> </div> <?php } if ($mango_settings['mango_show_wishlist_button']) { if (in_array('yith-woocommerce-wishlist/init.php', apply_filters('active_plugins', get_option('active_plugins')))) { echo do_shortcode('[yith_wcwl_add_to_wishlist]'); } } ?> <div class="img-effect"> <?php echo '<a href="' . get_the_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, 'product-thumbnail', array("class" => "product-image")) . '</a>'; if ($attachment_ids) { foreach ($attachment_ids as $attachment_id) { $image_link = wp_get_attachment_url($attachment_id); echo '<a class="hover-img" href="' . get_the_permalink() . '" title="' . get_the_title() . '">' . wp_get_attachment_image($attachment_id, 'product-image') . '</a>'; } } ?> </div> <div class="product-action-container"> <?php if ($mango_settings['mango_show_add_to_cart_button']) { 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="product-btn product-add-btn %s product_type_%s"><i class="fa fa-shopping-cart"></i>%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); } ?> </div><!-- end .product-action-container --> </div><!-- End .product-top --> <?php if ($show_cat == 'yes') { ?> <div class="product-cats"><?php echo $product_cats; ?> </div><!-- End .product-cats --> <?php } ?> <h3 class="product-title"><a href="<?php echo get_the_permalink(); ?> " title="<?php get_the_title(); ?> "><?php echo get_the_title(); ?> </a></h3> <?php if ($show_rating == 'yes') { ?> <?php if ($rating_html = $product->get_rating_html()) { $rating = $product->get_average_rating(); $rating_html = $product->get_rating_html(); $count = 0; ?> <div class="product-ratings"> <?php for ($i = 0; $i < (int) $rating; $i++) { $count++; echo '<span class="star active"></span>'; } if ($rating - (int) $rating >= 0.5) { $count++; echo '<span class="star active-half"></span>'; } for ($i = $count; $i < 5; $i++) { $count++; echo '<span class="star"></span>'; } ?> <span class="rating-amount"> <?php $rev_count = $product->get_review_count(); echo $rev_count . " "; if ($rev_count == 0 || $rev_count > 1) { _e("Reviews", 'mango'); } elseif ($rev_count == 1) { _e("Review", 'mango'); } ?> </span> </div> <?php } ?> <?php } ?> <?php if ($show_price == 'yes') { ?> <?php wc_get_template_part("loop/price"); ?> <?php } ?> </div><!-- End .product --> <?php } } } ?> </div><!-- End .col-md-3 --> <!--******************** QUICK VIEW START ******************************--> <?php if (have_posts()) { while (have_posts()) { the_post(); global $product, $woocommerce; $product_cats = $product->get_categories(' | ', '', ''); $attachment_ids = $product->get_gallery_attachment_ids(); ?> <div id="product-popup_<?php echo the_ID(); ?> " class="overlay-popup mypopup mfp-hide"> <div itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?> " id="product-<?php the_ID(); ?> " <?php post_class("row"); ?> > <?php //do_action( 'woocommerce_before_single_product_summary' ); ?> <div class="col-md-6 col-sm-6"> <div class="images product-gallery-container"> <div class="product-top "> <?php woocommerce_show_product_sale_flash(); if (has_post_thumbnail()) { $image_title = esc_attr(get_the_title(get_post_thumbnail_id())); $image_caption = get_post(get_post_thumbnail_id())->post_excerpt; $image_link = wp_get_attachment_url(get_post_thumbnail_id()); $image = get_the_post_thumbnail($post->ID, apply_filters('single_product_large_thumbnail_size', 'shop_single'), array('title' => $image_title, 'alt' => $image_title)); $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); //single-product // $image = $image['0']; $zoom_img = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $zoom_img = $zoom_img['0']; echo apply_filters("woocommerce_single_product_image_html", sprintf('<img class="product-zoom" src="%s" data-zoom-image="%s" alt="%s"/>', $zoom_img, $zoom_img, $image_title), $post->ID); } else { echo apply_filters('woocommerce_single_product_image_html', sprintf('<img class="product-zoom" src="%s" data-zoom-image="%s" alt="%s" />', wc_placeholder_img_src(), wc_placeholder_img_src(), __('Placeholder', 'woocommerce')), $post->ID); } ?> </div> <?php // do_action( 'woocommerce_product_thumbnails' ); $attachment_ids = $product->get_gallery_attachment_ids(); if (has_post_thumbnail()) { if (empty($attachment_ids)) { $attachment_ids[] = get_post_thumbnail_id($post->ID); } else { array_unshift($attachment_ids, get_post_thumbnail_id($post->ID)); } } if ($attachment_ids) { $loop = 0; $columns = apply_filters('woocommerce_product_thumbnails_columns', 3); ?> <div class="product-gallery-wrapper thumbnails <?php echo 'columns-' . $columns; ?> "> <div class="product-quick"> <?php foreach ($attachment_ids as $attachment_id) { $image = wp_get_attachment_image_src($attachment_id, apply_filters('single_product_small_thumbnail_size', 'shop_single')); $image_zoom = wp_get_attachment_image_src($attachment_id, apply_filters('single_product_small_thumbnail_size', 'full')); $image_class = 'product-gallery-item'; $image_title = esc_attr(get_the_title($attachment_id)); ?> <div class="gallery_images"> <a href="#" data-image="<?php echo $image[0]; ?> " data-zoom-image="<?php echo $image_zoom[0]; ?> " class="<?php echo $image_class; ?> " title="<?php echo $image_title; ?> "><img src="<?php echo $image[0]; ?> " alt="<?php echo $image_title; ?> "/></a> </div> <?php } ?> <div class="clearfix"></div> </div> </div> <?php } ?> </div> </div> <div class="col-md-6 col-sm-6"> <div class="summary entry-summary"> <div class="product-details text-left"> <?php do_action('woocommerce_single_product_summary'); ?> </div> </div> <!-- .summary --> <?php do_action('woocommerce_after_single_product_summary'); ?> <meta itemprop="url" content="<?php the_permalink(); ?> " /> </div> <!--col-md-6--> </div> <!-- #product-<?php the_ID(); ?> --> <?php do_action('woocommerce_after_single_product'); ?> </div><?php } } ?> <script type="text/javascript"> jQuery( document ).ready(function() { /* swap images for zoom on click event */ jQuery('.product-quick').find('a').on('click', function (e) { var ez = jQuery('.product-zoom').data('elevateZoom'), smallImg = jQuery(this).data('image'), bigImg = jQuery(this).data('zoom-image'); ez.swaptheimage(smallImg, bigImg); e.preventDefault(); }) }) </script> <!-- ************************ QUICK VIEW END ******************* --> </div> <?php wp_reset_query(); $output = ob_get_clean(); return $output; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $number = $instance['number']; $style = $instance['style']; $categories = $instance['categories']; $type = $instance['product_type']; echo $before_widget; if ($title) { echo $before_title . esc_attr($title) . $after_title; } if ($style == 'style1') { ?> <ul class="products-list"> <?php $query_arg = array('post_type' => 'product', 'posts_per_page' => $number, 'product_cat' => $categories); if ($type == 'Featured') { $query_arg['meta_key'] = '_featured'; $query_arg['meta_value'] = 'yes'; } else { if ($type == 'Bestselling') { $query_arg['post__in'] = mango_woocomerce_bestsellers(); } } $s = new WP_Query($query_arg); if ($s->have_posts()) { while ($s->have_posts()) { global $product; $s->the_post(); $category = get_term_by('name', $categories, 'product_cat'); $product = get_product($s->post->ID); ?> <li> <?php $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($product->id)); ?> <?php if (has_post_thumbnail($product->id) && !post_password_required()) { ?> <figure> <a href="<?php the_permalink(); ?> "> <img src="<?php echo esc_url($img_src[0]); ?> " alt="<?php the_title(); ?> " class="product-image"></a> </figure> <?php } else { $image = plugin_dir_url(__DIR__) . "img/dummy-img.jpg"; ?> <figure> <a href="<?php the_permalink(); ?> "> <img src="<?php echo esc_url($image); ?> " alt="<?php the_title(); ?> " class="product-image"></a> </figure> <?php } ?> <h5 class="product-title"> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </h5> <div class="product-price-container"> <?php if ($product->get_regular_price() && $product->get_sale_price()) { ?> <span class="product-old-price"><?php echo get_woocommerce_currency_symbol(); echo $product->get_regular_price(); ?> </span> <span class="product-price"><?php echo get_woocommerce_currency_symbol(); echo $product->get_sale_price(); ?> </span> <?php } elseif ($product->get_sale_price()) { ?> <span class="product-price"><?php echo get_woocommerce_currency_symbol(); echo $product->get_sale_price(); ?> </span> <?php } elseif ($product->get_regular_price()) { ?> <span class="product-price"><?php echo get_woocommerce_currency_symbol(); echo $product->get_regular_price(); ?> </span> <?php } ?> <?php if ($rating_html = $product->get_rating_html()) { $rating = $product->get_average_rating(); $rating_html = $product->get_rating_html(); $count = 0; ?> <div class="product-ratings"> <?php for ($i = 0; $i < (int) $rating; $i++) { $count++; echo '<span class="star active"></span>'; } if ($rating - (int) $rating >= 0.5) { $count++; echo '<span class="star active-half"></span>'; } for ($i = $count; $i < 5; $i++) { $count++; echo '<span class="star"></span>'; } ?> <span class="rating-amount"> <?php $rev_count = $product->get_review_count(); echo $rev_count . " "; if ($rev_count == 0 || $rev_count > 1) { _e("Reviews", 'mango'); } elseif ($rev_count == 1) { _e("Review", 'mango'); } ?> </span> </div> <?php } ?> </div><!-- End .product-price-container --> </li> <?php } wp_reset_query(); } ?> </ul> <?php } if ($style == 'style2') { ?> <div class="widget widget-products"> <ul class="products-list border-none"> <?php $query_arg = array('post_type' => 'product', 'posts_per_page' => $number, 'product_cat' => $categories); if ($type == 'Featured') { $query_arg['meta_key'] = '_featured'; $query_arg['meta_value'] = 'yes'; } else { if ($type == 'Bestselling') { $query_arg['post__in'] = mango_woocomerce_bestsellers(); } } $s = new WP_Query($query_arg); if ($s->have_posts()) { while ($s->have_posts()) { global $product; $s->the_post(); $category = get_term_by('name', $categories, 'product_cat'); $product = get_product($s->post->ID); ?> <li> <?php $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($product->id)); ?> <?php if (has_post_thumbnail($product->id) && !post_password_required()) { ?> <figure> <a class="mango-popular" href="<?php the_permalink(); ?> "> <img src="<?php echo esc_url($img_src[0]); ?> " alt="<?php the_title(); ?> " class="product-image"></a> </figure> <?php } else { $image = plugin_dir_url(__DIR__) . "img/dummy-img.jpg"; ?> <figure> <a class="mango-popular" href="<?php the_permalink(); ?> "> <img src="<?php echo esc_url($image); ?> " alt="<?php the_title(); ?> " class="product-image"></a> </figure> <?php } ?> <h5 class="product-title"><a class="mango-popular" href="<?php echo get_the_permalink(); ?> " title="<?php echo get_the_title(); ?> "><?php echo get_the_title(); ?> </a> </h5> <div class="product-price-container"> <?php if ($product->get_regular_price() && $product->get_sale_price()) { ?> <span class="product-old-price"><?php echo get_woocommerce_currency_symbol(); echo $product->get_regular_price(); ?> </span> <span class="product-price"><?php echo get_woocommerce_currency_symbol(); echo $product->get_sale_price(); ?> </span> <?php } elseif ($product->get_sale_price()) { ?> <span class="product-price"><?php echo get_woocommerce_currency_symbol(); echo $product->get_sale_price(); ?> </span> <?php } elseif ($product->get_regular_price()) { ?> <span class="product-price"><?php echo get_woocommerce_currency_symbol(); echo $product->get_regular_price(); ?> </span> <?php } ?> <?php if ($rating_html = $product->get_rating_html()) { $rating = $product->get_average_rating(); $rating_html = $product->get_rating_html(); $count = 0; ?> <div class="product-ratings"> <?php for ($i = 0; $i < (int) $rating; $i++) { $count++; echo '<span class="star active"></span>'; } if ($rating - (int) $rating >= 0.5) { $count++; echo '<span class="star active-half"></span>'; } for ($i = $count; $i < 5; $i++) { $count++; echo '<span class="star"></span>'; } ?> <span class="rating-amount"> <?php $rev_count = $product->get_review_count(); echo $rev_count . " "; if ($rev_count == 0 || $rev_count > 1) { _e("Reviews", 'mango'); } elseif ($rev_count == 1) { _e("Review", 'mango'); } ?> </span> </div> <?php } ?> </div><!-- End .product-price-container --> </li> <?php } wp_reset_query(); } ?> </ul> </div> <?php } echo $after_widget; }