function show_product_gallery() { global $post, $product, $woocommerce; $small_thumbnail_size = apply_filters('single_product_small_thumbnail_size', 'shop_single'); $attachments = $product->get_gallery_attachment_ids(); if ($attachments) { $loop = 0; $columns = apply_filters('woocommerce_product_thumbnails_columns', 3); $post_title = esc_attr(get_the_title(get_post_thumbnail_id($post->ID))); echo '<div class="product-gallery images"><ul class="slides">'; if (has_post_thumbnail()) { $small_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'shop_thumbnail'); $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'shop_single'); $full_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $lightbox_rel = ''; if ('yes' == get_option('woocommerce_enable_lightbox')) { $lightbox_rel = ' data-rel="prettyPhoto[product-gallery]"'; } echo '<li data-thumb="' . $small_image_url[0] . '"><a href="' . $full_image_url[0] . '" title="' . $post_title . '" rel="thumbnails" class="zoom "' . $lightbox_rel . '>' . get_the_post_thumbnail($post->ID, 'shop_single') . '</a></li>'; } foreach ($attachments as $attachment_id) { if (get_post_meta($attachment_id, '_woocommerce_exclude_image', true) == 1) { continue; } $loop++; $url = wp_get_attachment_image_src($attachment_id, 'shop_thumbnail'); $url_large = wp_get_attachment_image_src($attachment_id, 'shop_single'); $image = wp_get_attachment_image($attachment_id, $small_thumbnail_size); $post_title = esc_attr(get_the_title($attachment_id)); if ('yes' == get_option('woocommerce_enable_lightbox')) { $lightbox_rel = ' data-rel="prettyPhoto[product-gallery]"'; } echo '<li data-thumb="' . $url[0] . '"><a href="' . $url_large[0] . '" title="' . $post_title . '" rel="thumbnails" class="zoom '; if ($loop == 1 || ($loop - 1) % $columns == 0) { echo 'first'; } if ($loop % $columns == 0) { echo 'last'; } echo '"' . $lightbox_rel . '>' . $image . '</a></li>'; } echo '</ul></div>'; } else { woocommerce_show_product_images(); } }
<!-- =================================== --> <!-- =================================== --> <?php get_template_part('includes/item-booking'); ?> <?php } else { ?> <div class="row"> <div class="col-md-8"> <?php woocommerce_show_product_images(); ?> <?php /** * woocommerce_before_single_product_summary hook * * @hooked woocommerce_show_product_sale_flash - 10 * @hooked woocommerce_show_product_images - 20 */ //do_action( 'woocommerce_before_single_product_summary' ); ?> </div> <div class="col-md-4"> <div class="purchase-console summary entry-summary">
function wd_custom_products_category_function($atts, $content) { $_actived = apply_filters('active_plugins', get_option('active_plugins')); if (!in_array("woocommerce/woocommerce.php", $_actived)) { return; } global $woocommerce, $woocommerce_loop; if (empty($atts)) { return; } extract(shortcode_atts(array('per_page' => '4', 'orderby' => 'title', 'order' => 'desc', 'category' => '', 'show_image' => 1, 'show_title' => 1, 'show_sku' => 1, 'show_price' => 1, 'show_rating' => 1, 'show_label' => 1, 'show_categories' => 1, 'show_short_content' => 1), $atts)); //remove_action( 'woocommerce_before_shop_loop_item_title', 'custom_product_thumbnail', 10 ); if (!(int) $show_image) { remove_action('woocommerce_before_shop_loop_item_title', 'wd_template_loop_product_thumbnail', 10); } if (!(int) $show_categories) { remove_action('woocommerce_after_shop_loop_item', 'get_product_categories', 2); } if (!(int) $show_title) { remove_action('woocommerce_after_shop_loop_item', 'add_product_title', 3); } if (!(int) $show_sku) { remove_action('woocommerce_after_shop_loop_item', 'add_sku_to_product_list', 4); } if (!(int) $show_short_content) { remove_action('woocommerce_after_shop_loop_item', 'add_short_content', 5); } if (!(int) $show_price) { remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_price', 6); } if (!(int) $show_rating) { remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_rating', 7); } if (!(int) $show_label) { remove_action('woocommerce_before_shop_loop_item_title', 'add_label_to_product_list', 5); } if (!$category) { return; } wp_reset_query(); global $featured_datas, $data, $product, $post; $temp_add_to_cart_data = ''; $_featured_prod = wd_featured_by_category_function($category, 1); if (isset($_featured_prod)) { //$_featured_prod->get_upsells( ); $featured_datas = array('id' => $_featured_prod->id, 'show_image' => $show_image, 'show_title' => $show_title, 'show_sku' => $show_sku, 'show_price' => $show_price, 'show_rating' => $show_rating, 'show_label' => $show_label); $per_page = $per_page; $temp_add_to_cart_data = do_shortcode('[add_to_cart style="" show_price="false" id="' . $_featured_prod->id . '"]'); } else { $featured_datas = array('id' => '', 'show_image' => $show_image, 'show_title' => $show_title, 'show_sku' => $show_sku, 'show_price' => $show_price, 'show_rating' => $show_rating, 'show_label' => $show_label); $per_page = $per_page + 1; } // Default ordering args $ordering_args = $woocommerce->query->get_catalog_ordering_args($orderby, $order); $args = array('post_type' => 'product', 'post__not_in' => array($featured_datas['id']), 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $ordering_args['orderby'], 'order' => $ordering_args['order'], 'posts_per_page' => $per_page, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')), 'tax_query' => array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN'))); if (isset($ordering_args['meta_key'])) { $args['meta_key'] = $ordering_args['meta_key']; } ob_start(); $_old_woocommerce_loop_columns = $woocommerce_loop['columns']; if (isset($data['wd_prod_cat_column']) && absint($data['wd_prod_cat_column']) > 0) { $_old_wd_prod_cat_column = $data['wd_prod_cat_column']; $data['wd_prod_cat_column'] = 3; } $products = new WP_Query($args); $woocommerce_loop['columns'] = 3; $_count = 0; $_prod_cat = get_term_by('slug', esc_attr($category), 'product_cat'); if (isset($_prod_cat)) { $title = $_prod_cat->name; } $_random_id = 'custom_category_shortcode_' . rand(); if ($products->have_posts()) { ?> <div class="featured_product_slider_wrapper custom_category_shortcode" id="<?php echo $_random_id; ?> " data_column="3"> <?php remove_action('woocommerce_product_thumbnails', 'wd_template_shipping_return', 30); remove_action('woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20); $check_feature = 0; ?> <?php while ($products->have_posts()) { ?> <?php $products->the_post(); if ($_count == 0) { $old_prod = $product; $old_post = $post; echo '<div class="span12">'; $old_data = $data['wd_prod_cloudzoom']; $data['wd_prod_cloudzoom'] = 0; if (!isset($_featured_prod)) { $featured_datas['id'] = $product->id; //woocommerce_get_product_thumbnail('shop_catalog'); $product = get_product($post->ID); $post = $product->post; woocommerce_show_product_images(); } else { $product = get_product($featured_datas['id']); $post = $product->post; //print_r($post); //the_post_thumbnail(); //woocommerce_get_product_thumbnail('shop_catalog'); woocommerce_show_product_images(); } ?> <?php global $data; if (!isset($data['wd_catelog_mod']) || isset($data['wd_catelog_mod']) && $data['wd_catelog_mod'] == 1) { ?> <div class='list_add_to_cart'> <?php //for feature product if ($temp_add_to_cart_data != '') { echo $temp_add_to_cart_data; } else { echo do_shortcode('[add_to_cart id="' . $product->id . '"]'); } ?> </div> <?php } echo '<input type="hidden" value="' . $product->id . '" class="hidden_product_id product_hidden_' . $product->id . '">'; $data['wd_prod_cloudzoom'] = $old_data; echo '</div><div class="span12">'; $temp_class = ''; if ($product->is_on_sale() || $product->is_featured()) { $temp_class = 'has_label'; } echo '<div class="wd_product_heading ' . $temp_class . '"><a class="wd_feature_title" title="' . $product->post->post_title . '" href="' . get_permalink($product->post->ID) . '">' . $product->post->post_title . '</a>'; $span_label = '<div class="product_label">'; if ($product->is_on_sale()) { $span_label .= '<span class="onsale product_label">Sale</span>'; } if ($product->is_featured()) { $span_label .= '<span class="featured product_label">Featured</span>'; } $span_label .= '</div>'; echo $span_label; echo '</div><div class="wd_description">' . $product->post->post_excerpt . '</div>'; if (isset($_featured_prod)) { $product = $old_prod; $post = $old_post; if ($check_feature == 0) { $_count++; $check_feature = 1; } } woocommerce_product_loop_start(); } if ($_count > 0 && $_count < $per_page && function_exists('woocommerce_get_template_part')) { woocommerce_get_template_part('content', 'product'); } $_count++; ?> <?php } // end of the loop. ?> <?php woocommerce_product_loop_end(); ?> <?php if ($per_page > 4 && $products->post_count > 4) { ?> <div class="wd_slider_control"> <a title="prev" id="<?php echo $_random_id; ?> _prev" class="prev" href="#"><</a> <a title="next" id="<?php echo $_random_id; ?> _next" class="next" href="#">></a> </div> <?php } ?> <?php echo '</div>'; ?> </div> <script type='text/javascript'> //<![CDATA[ jQuery(document).ready(function() { "use strict"; // Using custom configuration var is_mobile = 0; <?php if (wp_is_mobile()) { ?> is_mobile = 1; <?php } ?> var temp_visible = 3; if(is_mobile && jQuery(window).width() >= 768 && jQuery(window).width() <= 1024){ temp_visible = temp_visible - 1; } if(is_mobile && jQuery(window).width() < 768){ //temp_visible = '{ min : 1,max : <?php echo $columns; ?> }'; temp_visible = 1; } var _slider_datas = { items : { /*width: 140 ,height: <?php echo strcmp($layout, 'small') == 0 ? 240 : 650; ?> */ width: <?php echo wp_is_mobile() ? 300 : 200; ?> ,height: 'auto' ,visible: temp_visible } ,direction : "left" ,responsive : true ,swipe : { /*onMouse: true, */onTouch: true } ,scroll : <?php if (!wp_is_mobile()) { ?> { //items :1, duration : 1000 , pauseOnHover:true , easing : "linear"} <?php } else { ?> 1 <?php } ?> ,width : '100%' ,height : '100%' ,circular : true ,infinite : true ,auto : false ,onCreate : function(){ //alert(jQuery(this).html()); } <?php if ($per_page > 4 && $products->post_count > 3) { ?> ,prev : '#<?php echo $_random_id; ?> _prev' ,next : '#<?php echo $_random_id; ?> _next' <?php } ?> //<?php if ($show_icon_nav) { ?> //,pagination : '#<?php echo $_random_id; ?> _pager' //<?php } ?> }; //setTimeout(function(){ jQuery("#<?php echo $_random_id; ?> ul.products").carouFredSel(_slider_datas); //},10000); var temp_custom = jQuery("#<?php echo $_random_id; ?> ").closest(".tabbable").addClass('has_slider'); jQuery(temp_custom).bind('tabs_change',jQuery.debounce( 250, function(event, id){ var my_id = '<?php echo $_random_id; ?> '; if(id == my_id){ var _item_width = jQuery(window).width() < 600 ? 300: 200; _slider_datas.items.width = _item_width; _slider_datas.items.visible = temp_visible; //jQuery("#<?php echo $_random_id; ?> > .featured_product_slider_wrapper_inner ul.products").trigger('destroy',true); jQuery("#<?php echo $_random_id; ?> ul.products").trigger('configuration ',["items.width", 200, true]); setTimeout(function(){ jQuery("#<?php echo $_random_id; ?> ul.products").carouFredSel(_slider_datas); jQuery("#<?php echo $_random_id; ?> ul.products li").show(); //jQuery("#<?php echo $_random_id; ?> ").closest(".tab-pane").css('visibility','visible'); jQuery("#<?php echo $_random_id; ?> ").closest(".tab-pane").css('height','auto'); jQuery(temp_custom).children('.tab-content').removeClass('wd_loading'); },200); } } )); }); //]]> </script> <?php } wp_reset_postdata(); //add all the hook removed add_action('woocommerce_after_shop_loop_item', 'open_div_style', 1); add_action('woocommerce_after_shop_loop_item', 'get_product_categories', 2); add_action('woocommerce_after_shop_loop_item', 'add_product_title', 3); add_action('woocommerce_after_shop_loop_item', 'add_sku_to_product_list', 4); add_action('woocommerce_after_shop_loop_item', 'add_short_content', 5); add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_price', 6); add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_rating', 7); add_action('woocommerce_before_shop_loop_item_title', 'add_label_to_product_list', 5); add_action('woocommerce_before_shop_loop_item_title', 'wd_template_loop_product_thumbnail', 10); add_action('woocommerce_product_thumbnails', 'wd_template_shipping_return', 30); add_action('woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20); //end $woocommerce_loop['columns'] = $_old_woocommerce_loop_columns; if (isset($_old_wd_prod_cat_column) && absint($_old_wd_prod_cat_column > 0)) { $data['wd_prod_cat_column'] = $_old_wd_prod_cat_column; } return '<div class="woocommerce">' . ob_get_clean() . '</div>'; }
public function wpv_woo_product_image_func($atts) { if (isset($atts) && !empty($atts)) { //Process size attributes if (isset($atts['size'])) { global $attribute_image_size; $attribute_image_size = $atts['size']; add_filter('single_product_large_thumbnail_size', array(&$this, 'wcviews_set_image_size_closures')); } //Filter for raw image output, not image link if (isset($atts['output'])) { if ($atts['output'] == 'img_tag') { add_filter('woocommerce_single_product_image_html', array(&$this, 'show_raw_image_html_wc_views'), 10, 2); } elseif ($atts['output'] == 'raw') { add_filter('woocommerce_single_product_image_html', array(&$this, 'show_raw_image_url_wc_views'), 20, 2); } } //Filter for display of galleries in listings if (isset($atts['gallery_on_listings'])) { //Retrieved value $gallery_on_listings = $atts['gallery_on_listings']; if (!empty($gallery_on_listings)) { $gallery_on_listings = strtolower($gallery_on_listings); if ('yes' == $gallery_on_listings) { remove_filter('woocommerce_product_gallery_attachment_ids', array(&$this, 'remove_gallery_on_main_image_at_listings'), 20, 2); } } } } //Reordered ob_start(); global $post, $woocommerce; $product = $this->wcviews_setup_product_data($post); //Fix placeholder image size for those without featured image set if (!has_post_thumbnail()) { add_filter('woocommerce_single_product_image_html', array(&$this, 'adjust_wc_views_image_placeholder'), 10, 2); } else { remove_filter('woocommerce_single_product_image_html', array(&$this, 'adjust_wc_views_image_placeholder'), 10, 2); } if (isset($product)) { woocommerce_show_product_images(); $image_content = ob_get_contents(); //Image processing to remove Woocommerce <div> tags around the image HTML if user wants to output img_tag only or raw URL if (isset($atts['output'])) { if ($atts['output'] == 'img_tag' || $atts['output'] == 'raw') { $image_content = trim(strip_tags($image_content, '<img>')); } } ob_end_clean(); } else { $image_content = ob_get_contents(); ob_end_clean(); } return $image_content; }
function dt_woocommerce_show_product_images() { global $product; ob_start(); woocommerce_show_product_images(); $content = ob_get_clean(); if ($product->is_featured()) { $content = str_replace('<div class="images">', '<div class="images"><span class="featured-product">' . __('Featured', 'dt_delicate') . '</span>', $content); } echo $content; }