function sw_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0) { global $post; $html = ''; $id = get_the_ID(); $gallery = get_post_meta($id, '_product_image_gallery', true); $attachment_image = ''; if (!empty($gallery)) { $gallery = explode(',', $gallery); $first_image_id = $gallery[0]; $attachment_image = wp_get_attachment_image($first_image_id, $size, false, array('class' => 'hover-image back')); } $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), ''); if (has_post_thumbnail()) { if ($attachment_image) { $html .= '<div class="product-thumb-hover">'; $html .= get_the_post_thumbnail($post->ID, $size); $html .= $attachment_image; $html .= '</div>'; } else { $html .= get_the_post_thumbnail($post->ID, $size); } return $html; } elseif (wc_placeholder_img_src()) { $html .= wc_placeholder_img($size); return $html; } }
function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0) { global $product; if ($product->is_type('variable')) { global $prdctfltr_global; $pf_activated = isset($prdctfltr_global['active_filters']) ? $prdctfltr_global['active_filters'] : array(); if (!empty($pf_activated)) { $attrs = array(); foreach ($pf_activated as $k => $v) { if (substr($k, 0, 3) == 'pa_') { $attrs = $attrs + array($k => $v[0]); } } if (count($attrs) > 0) { $curr_var = $product->get_available_variations(); foreach ($curr_var as $key => $var) { $curr_var_set[$key]['attributes'] = $var['attributes']; $curr_var_set[$key]['variation_id'] = $var['variation_id']; } $found = WC_Prdctfltr::prdctrfltr_search_array($curr_var_set, $attrs); } } } if (isset($found[0]) && $found[0]['variation_id'] && has_post_thumbnail($found[0]['variation_id'])) { $image = get_the_post_thumbnail($found[0]['variation_id'], $size); } elseif (has_post_thumbnail($product->id)) { $image = get_the_post_thumbnail($product->id, $size); } elseif (($parent_id = wp_get_post_parent_id($product->id)) && has_post_thumbnail($parent_id)) { $image = get_the_post_thumbnail($product, $size); } else { $image = wc_placeholder_img($size); } return $image; }
function woocommerce_get_product_thumbnail($size = 'news-thumb', $placeholder_width = 0, $placeholder_height = 0) { global $post; if (has_post_thumbnail()) { return get_the_post_thumbnail($post->ID, $size, array('class' => 'img-responsive')); } elseif (wc_placeholder_img_src()) { return wc_placeholder_img($size); } }
function spyropress_wc_product_thumbnail() { $image = ''; if (has_post_thumbnail()) { $image = get_image(array('echo' => false, 'class' => 'img-responsive')); } elseif (wc_placeholder_img_src()) { $image = wc_placeholder_img('shop_single'); } echo ' <a href="' . get_permalink() . '"> <span class="product-thumb-info-image"> <span class="product-thumb-info-act"> <span class="product-thumb-info-act-left"><em>' . __('View', 'spyropress') . '</em></span> <span class="product-thumb-info-act-right"><em><i class="icon icon-plus"></i> ' . __('Details', 'spyropress') . '</em></span> </span> ' . str_replace('wp-post-image', 'img-responsive', $image) . ' </span> </a>'; }
/** * Returns the main product image * * @param string $size (default: 'shop_thumbnail') * @return string */ public function get_image($size = 'shop_thumbnail', $attr = array()) { if (has_post_thumbnail($this->id)) { $image = get_the_post_thumbnail($this->id, $size, $attr); } elseif (($parent_id = wp_get_post_parent_id($this->id)) && has_post_thumbnail($parent_id)) { $image = get_the_post_thumbnail($parent_id, $size, $attr); } else { $image = wc_placeholder_img($size); } return $image; }
/** * Get the product thumbnail, or the placeholder if not set. * * @access public * @subpackage Loop * @param string $size (default: 'shop_catalog') * @param int $placeholder_width (default: 0) * @param int $placeholder_height (default: 0) * @return string */ function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0) { global $post; if (has_post_thumbnail()) { return get_the_post_thumbnail($post->ID, $size); } elseif (wc_placeholder_img_src()) { return wc_placeholder_img($size); } }
function dtwl_product_thumbnail() { global $post; $size = 'shop_thumbnail'; if (has_post_thumbnail()) { echo get_the_post_thumbnail($post->ID, $size, array('class' => "attachment-{$size}")); } elseif (wc_placeholder_img_src()) { echo wc_placeholder_img($size); } }
/** * Returns the main product image. * * @param string $size (default: 'shop_thumbnail') * @param array $attr * @param bool True to return $placeholder if no image is found, or false to return an empty string. * @return string */ public function get_image($size = 'shop_thumbnail', $attr = array(), $placeholder = true) { if (has_post_thumbnail($this->id)) { $image = get_the_post_thumbnail($this->id, $size, $attr); } elseif (($parent_id = wp_get_post_parent_id($this->id)) && has_post_thumbnail($parent_id)) { $image = get_the_post_thumbnail($parent_id, $size, $attr); } elseif ($placeholder) { $image = wc_placeholder_img($size); } else { $image = ''; } return str_replace(array('https://', 'http://'), '//', $image); }
function woocommerce_get_product_thumbnail($size = 'product_small_thumbnail', $placeholder_width = 0, $placeholder_height = 0) { global $post; if (has_post_thumbnail()) { $image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'shop_catalog'); return get_the_post_thumbnail($post->ID, $size, array('data-src' => $image_src[0], 'class' => 'lazyOwl')); } elseif (wc_placeholder_img_src()) { return wc_placeholder_img($size); } }
/** * Test wc_placeholder_img() * * @since 2.4 */ public function test_wc_placeholder_img() { $sizes = array('shop_thumbnail' => array('width' => '180', 'height' => '180'), 'shop_single' => array('width' => '600', 'height' => '600'), 'shop_catalog' => array('width' => '300', 'height' => '300')); foreach ($sizes as $size => $values) { $img = '<img src="' . wc_placeholder_img_src() . '" alt="' . __('Placeholder', 'woocommerce') . '" width="' . $values['width'] . '" class="woocommerce-placeholder wp-post-image" height="' . $values['height'] . '" />'; $this->assertEquals(apply_filters('woocommerce_placeholder_img', $img), wc_placeholder_img($size)); } $img = '<img src="' . wc_placeholder_img_src() . '" alt="' . __('Placeholder', 'woocommerce') . '" width="180" class="woocommerce-placeholder wp-post-image" height="180" />'; $this->assertEquals(apply_filters('woocommerce_placeholder_img', $img), wc_placeholder_img()); }
/** * Get the product thumbnail, or the placeholder if not set. * * @subpackage Loop * @param string $size (default: 'shop_catalog') * @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0) * @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0) * @return string */ function woocommerce_get_product_thumbnail($size = 'shop_catalog', $deprecated1 = 0, $deprecated2 = 0) { global $post; if (has_post_thumbnail() && wp_attachment_is_image(get_post_thumbnail_id())) { return get_the_post_thumbnail($post->ID, $size); } elseif (wc_placeholder_img_src()) { return wc_placeholder_img($size); } }
function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0) { global $post; if (has_post_thumbnail()) { return "<div class=\"imageswrap productthumbnail\"><div class=\"imageHOpacity\"></div>" . get_the_post_thumbnail($post->ID, $size) . "</div>"; } elseif (wc_placeholder_img_src()) { return wc_placeholder_img($size); } }
function woocommerce_template_loop_product_thumbnail($view = 'grid-view') { global $woocommerce_loop, $post, $media_center_theme_options, $woocommerce_loop; $product_item_size = isset($woocommerce_loop['product_item_size']) ? $woocommerce_loop['product_item_size'] : $media_center_theme_options['product_item_size']; switch ($product_item_size) { case 'size-medium': $image_size = 'product-medium'; break; case 'size-small': $image_size = 'product-small'; break; case 'size-big': $image_size = 'product-large'; break; default: $image_size = 'product-medium'; } if ($view == 'list-view') { $image_size = 'product-medium'; } echo '<div class="product-image">'; echo '<a href="' . get_permalink($post->ID) . '">'; if ($media_center_theme_options['lazy_loading']) { if (has_post_thumbnail($post->ID)) { $post_thumbnail_ID = get_post_thumbnail_id($post->ID); $post_thumbnail_src = wp_get_attachment_image_src($post_thumbnail_ID, $image_size); } else { $dimensions = wc_get_image_size($image_size); $post_thumbnail_src = array(wc_placeholder_img_src(), esc_attr($dimensions['width']), esc_attr($dimensions['height'])); } echo '<img class="post-image echo-lazy-loading" src="' . get_template_directory_uri() . '/assets/images/blank.gif" alt="" data-echo="' . $post_thumbnail_src[0] . '" width="' . $post_thumbnail_src[1] . '" height="' . $post_thumbnail_src[2] . '">'; } else { if (has_post_thumbnail($post->ID)) { echo get_the_post_thumbnail($post->ID, $image_size); } else { echo wc_placeholder_img($image_size); } } echo '</a>'; echo '</div>'; }
?> > <?php } ?> <?php do_action('woocommerce_before_shop_loop_item'); ?> <?php $image_html = ""; if (has_post_thumbnail()) { $image_html = wp_get_attachment_image(get_post_thumbnail_id(), 'shop_catalog'); } else { if (wc_placeholder_img_src()) { $image_html = wc_placeholder_img('shop_catalog'); } } ?> <?php if ($shop_product_listing == 'style1') { ?> <figure class="fresco"> <?php do_action('thb_product_badge'); ?> <?php echo $image_html; ?> <div class="overlay"></div>
protected function content($atts, $content = null) { $atts = shortcode_atts(array('per_page' => '', 'orderby' => 'name', 'order' => 'ASC', 'ids' => '', 'hide_empty' => 'true', 'parent' => '', 'autoheight' => true, 'autoplay' => false, 'mousedrag' => true, 'autoplayspeed' => 5000, 'slidespeed' => 200, 'carousel_skin' => '', 'desktop' => 4, 'desktopsmall' => 3, 'tablet' => 2, 'mobile' => 1, 'gutters' => true, 'navigation' => true, 'navigation_always_on' => true, 'navigation_position' => 'center-outside', 'navigation_style' => 'normal', 'pagination' => false, 'pagination_position' => 'center-bottom', 'pagination_style' => 'dot-stroke', 'css_animation' => '', 'animation_delay' => '', 'el_class' => '', 'css' => ''), $atts); $atts['columns'] = $atts['desktop']; $atts['number'] = $atts['per_page']; $atts['hide_empty'] = apply_filters('sanitize_boolean', $atts['hide_empty']); extract($atts); $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'products-brands-carousel ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'woocommerce' => 'woocommerce columns-' . $desktop, 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' ')); $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts), '', 'cruxstore-owl-carousel'); $output = $carousel_html = ''; if (isset($atts['ids'])) { $ids = explode(',', $atts['ids']); $ids = array_map('trim', $ids); } else { $ids = array(); } $hide_empty = $atts['hide_empty'] == true || $atts['hide_empty'] == 1 ? 1 : 0; // get terms and workaround WP bug with parents/pad counts $args = array('orderby' => $atts['orderby'], 'order' => $atts['order'], 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $atts['parent']); $product_brands = get_terms('yith_product_brand', $args); if ('' !== $atts['parent']) { $product_brands = wp_list_filter($product_brands, array('parent' => $atts['parent'])); } if ($hide_empty) { foreach ($product_brands as $key => $brand) { if ($brand->count == 0) { unset($product_brands[$key]); } } } if ($atts['number']) { $product_brands = array_slice($product_brands, 0, $atts['number']); } ob_start(); if ($product_brands) { global $woocommerce_carousel; $woocommerce_carousel = 'normal'; $css_animation = cruxstore_getCSSAnimation($css_animation); foreach ($product_brands as $key => $term) { if ($animation_delay) { $animation_delay_item = sprintf(' data-wow-delay="%sms"', $key * $animation_delay); } else { $animation_delay_item = ''; } echo '<div class="brand-banner' . $css_animation . '"' . $animation_delay_item . '><div class="brand-banner-content">'; $thumbnail_id = absint(yith_wcbr_get_term_meta($term->term_id, 'thumbnail_id', true)); $image_size = apply_filters('cruxstore_brand_logo', 'cruxstore_grid'); if ($thumbnail_id) { $image = wp_get_attachment_image_src($thumbnail_id, $image_size); printf('<div class="brand-image"><img src="%s" width="%d" height="%d" alt="%s"/></div>', $image[0], $image[1], $image[2], $term->name); } else { do_action('yith_wcbr_no_brand_logo', $term->term_id, $term, 'yith_wcbr_logo_size', false, false); echo '<div class="brand-image">' . wc_placeholder_img() . '</div>'; } printf('<h4 class="brand-count"><span>%s</span> %s</a></h4>', $term->count, esc_html__('Products', 'cruxstore')); printf('<a href="%s">%s</a>', get_term_link($term), $term->name); echo '</div></div>'; } } wp_reset_postdata(); $carousel_html .= ob_get_clean(); if ($carousel_html) { $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); $output = '<div class="' . esc_attr($elementClass) . '"><div class="products-brands-inner">' . str_replace('%carousel_html%', $carousel_html, $carousel_ouput) . '</div></div>'; } return $output; }
/** * Get the product thumbnail, or the placeholder if not set. * * @subpackage Loop * @param string $size (default: 'shop_catalog') * @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0) * @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0) * @return string */ function woocommerce_get_product_thumbnail($size = 'medium', $deprecated1 = 0, $deprecated2 = 0) { global $post; if (has_post_thumbnail()) { return get_the_post_thumbnail($post->ID, $size, array('class' => '[ image-responsive ]')); } elseif (wc_placeholder_img_src()) { return wc_placeholder_img($size); } }
/** * Get the product thumbnail, or the placeholder if not set. * * @subpackage Loop * @param string $size (default: 'shop_catalog') * @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0) * @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0) * @return string */ function woocommerce_get_product_thumbnail($size = 'shop_catalog', $deprecated1 = 0, $deprecated2 = 0) { global $post; $image_size = apply_filters('single_product_archive_thumbnail_size', $size); if (has_post_thumbnail()) { $props = wc_get_product_attachment_props(get_post_thumbnail_id(), $post); return get_the_post_thumbnail($post->ID, $image_size, array('title' => $props['title'], 'alt' => $props['alt'])); } elseif (wc_placeholder_img_src()) { return wc_placeholder_img($image_size); } }
function edit_category_fields($term, $taxonomy) { global $ts_default_sidebars; $sidebar_options = array(); foreach ($ts_default_sidebars as $key => $_sidebar) { $sidebar_options[$_sidebar['id']] = $_sidebar['name']; } $bg_breadcrumbs_id = get_woocommerce_term_meta($term->term_id, 'bg_breadcrumbs_id', true); $layout = get_woocommerce_term_meta($term->term_id, 'layout', true); $left_sidebar = get_woocommerce_term_meta($term->term_id, 'left_sidebar', true); $right_sidebar = get_woocommerce_term_meta($term->term_id, 'right_sidebar', true); ?> <tr class="form-field"> <th scope="row" valign="top"><label><?php esc_html_e('Breadcrumbs Background Image', 'gon'); ?> </label></th> <td> <div id="product_cat_bg_breadcrumbs"> <?php if (empty($bg_breadcrumbs_id)) { echo wc_placeholder_img('thumbnail'); } else { echo wp_get_attachment_image($bg_breadcrumbs_id, 'thumbnail'); } ?> </div> <div class="upload-button"> <input type="hidden" name="wc_placeholder_img_src" id="wc_placeholder_img_src" value="<?php echo esc_url(wc_placeholder_img_src()); ?> " /> <input type="hidden" name="product_cat_bg_breadcrumbs_id" id="product_cat_bg_breadcrumbs_id" value="<?php echo esc_attr($bg_breadcrumbs_id); ?> " /> <button type="button" class="product_cat_bg_breadcrumbs_upload_button button"><?php esc_html_e('Upload/Add image', 'gon'); ?> </button> <button type="button" class="product_cat_bg_breadcrumbs_remove_button button"><?php esc_html_e('Remove image', 'gon'); ?> </button> </div> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label><?php esc_html_e('Layout', 'gon'); ?> </label></th> <td> <select name="layout" id="layout"> <option value="" <?php selected($layout, ''); ?> ><?php esc_html_e('Default', 'gon'); ?> </option> <option value="0-1-0" <?php selected($layout, '0-1-0'); ?> ><?php esc_html_e('Fullwidth', 'gon'); ?> </option> <option value="1-1-0" <?php selected($layout, '1-1-0'); ?> ><?php esc_html_e('Left Sidebar', 'gon'); ?> </option> <option value="0-1-1" <?php selected($layout, '0-1-1'); ?> ><?php esc_html_e('Right Sidebar', 'gon'); ?> </option> <option value="1-1-1" <?php selected($layout, '1-1-1'); ?> ><?php esc_html_e('Left & Right Sidebar', 'gon'); ?> </option> </select> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label><?php esc_html_e('Left Sidebar', 'gon'); ?> </label></th> <td> <select name="left_sidebar" id="left_sidebar"> <option value="" <?php selected($left_sidebar, ''); ?> ><?php esc_html_e('Default', 'gon'); ?> </option> <?php foreach ($sidebar_options as $sidebar_id => $sidebar_name) { ?> <option value="<?php echo esc_attr($sidebar_id); ?> " <?php selected($left_sidebar, $sidebar_id); ?> ><?php echo esc_html($sidebar_name); ?> </option> <?php } ?> </select> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label><?php esc_html_e('Right Sidebar', 'gon'); ?> </label></th> <td> <select name="right_sidebar" id="right_sidebar"> <option value="" <?php selected($right_sidebar, ''); ?> ><?php esc_html_e('Default', 'gon'); ?> </option> <?php foreach ($sidebar_options as $sidebar_id => $sidebar_name) { ?> <option value="<?php echo esc_attr($sidebar_id); ?> " <?php selected($right_sidebar, $sidebar_id); ?> ><?php echo esc_html($sidebar_name); ?> </option> <?php } ?> </select> </td> </tr> <?php }
function porto_widget_product_thumbnail() { global $porto_settings; $id = get_the_ID(); $size = 'shop_thumbnail'; $gallery = get_post_meta($id, '_product_image_gallery', true); $attachment_image = ''; if (!empty($gallery) && $porto_settings['category-image-hover']) { $gallery = explode(',', $gallery); $first_image_id = $gallery[0]; $attachment_image = wp_get_attachment_image($first_image_id, $size, false, array('class' => 'hover-image ')); } $thumb_image = get_the_post_thumbnail($id, $size, array('class' => '')); if (!$thumb_image) { if (wc_placeholder_img_src()) { $thumb_image = wc_placeholder_img($size); } } echo '<div class="inner' . ($attachment_image ? ' img-effect' : '') . '">'; // show images echo $thumb_image; echo $attachment_image; echo '</div>'; }
function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0) { $product = get_product(get_the_ID()); $attrs = array(); foreach ($_GET as $k => $v) { if (substr($k, 0, 3) == 'pa_') { if (!strpos($v, ',')) { $v_val = $v; } else { $v_val = explode(',', $v); $v_val = $v_val[0]; } $attrs = $attrs + array($k => $v_val); } } if (count($attrs) == 0) { global $wp_the_query; if (isset($wp_the_query->query)) { foreach ($wp_the_query->query as $k => $v) { if (substr($k, 0, 3) == 'pa_') { if (!strpos($v, ',')) { $v_val = $v; } else { $v_val = explode(',', $v); $v_val = $v_val[0]; } $attrs = $attrs + array($k => $v_val); } } } } if (count($attrs) == 0) { global $prdctfltr_global; if (isset($prdctfltr_global['active_filters'])) { foreach ($prdctfltr_global['active_filters'] as $k => $v) { if (substr($k, 0, 3) == 'pa_') { if (!strpos($v, ',')) { $v_val = $v; } else { $v_val = explode(',', $v); $v_val = $v_val[0]; } $attrs = $attrs + array($k => $v_val); } } } } if (is_product_taxonomy()) { $attrs = array_merge($attrs, array(get_query_var('taxonomy') => get_query_var('term'))); } if (count($attrs) > 0) { if ($product->is_type('variable')) { $curr_var = $product->get_available_variations(); $si = prdctrfltr_search_array($curr_var, $attrs); } } if (isset($si[0]) && $si[0]['variation_id'] && has_post_thumbnail($si[0]['variation_id'])) { $image = get_the_post_thumbnail($si[0]['variation_id'], $size); } elseif (has_post_thumbnail($product->id)) { $image = get_the_post_thumbnail($product->id, $size); } elseif (($parent_id = wp_get_post_parent_id($product->id)) && has_post_thumbnail($parent_id)) { $image = get_the_post_thumbnail($product, $size); } else { $image = wc_placeholder_img($size); } return $image; }
protected function content($atts, $content = null) { $atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('tab_producs', $atts) : $atts; $atts = shortcode_atts(array('taxonomy' => '', 'size' => 'kt_shop_catalog_260', 'style' => '1', 'per_page' => 12, 'columns' => 4, 'border_heading' => '', 'css_animation' => '', 'el_class' => '', 'css' => '', 'autoplay' => 'false', 'navigation' => 'false', 'margin' => 30, 'slidespeed' => 200, 'css' => '', 'el_class' => '', 'nav' => 'true', 'loop' => 'false', 'use_responsive' => 1, 'items_destop' => 3, 'items_tablet' => 2, 'items_mobile' => 1), $atts); extract($atts); $this->product_size = $size; global $woocommerce_loop; $is_phone = false; if (function_exists('kt_is_phone') && kt_is_phone()) { $is_phone = true; } if ($style == 3) { $base_class = 'tab-product-13 option-13 style1 '; } else { $base_class = 'popular-tabs '; } $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $base_class, $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)); $elementClass = apply_filters('kt_product_tab_class_container', $elementClass); $tabs = array('best-sellers' => __('Best Sellers', 'kutetheme'), 'on-sales' => __('On Sales', 'kutetheme'), 'new-arrivals' => __('New Products', 'kutetheme')); $meta_query = WC()->query->get_meta_query(); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'meta_query' => $meta_query, 'suppress_filter' => true); if ($taxonomy) { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => explode(",", $taxonomy))); } add_filter('kt_product_thumbnail_loop', array(&$this, 'get_size_product')); $uniqeID = uniqid(); ob_start(); ?> <div class="<?php echo esc_attr($elementClass); ?> top-nav container-tab style<?php echo esc_attr($style); ?> "> <ul class="nav-tab"> <?php $i = 0; ?> <?php foreach ($tabs as $k => $v) { ?> <li <?php echo $i == 0 ? 'class="active"' : ''; ?> > <a data-toggle="tab" href="#tab-<?php echo esc_attr($k) . $uniqeID; ?> "><?php echo esc_html($v); ?> </a> </li> <?php $i++; ?> <?php } ?> </ul> <div class="tab-container"> <?php $data_carousel = array("autoplay" => $autoplay, "navigation" => $navigation, "margin" => $margin, "smartSpeed" => $slidespeed, "theme" => 'style-navigation-bottom', "autoheight" => 'false', 'nav' => $navigation, 'dots' => 'false', 'loop' => $loop, 'autoplayTimeout' => 1000, 'autoplayHoverPause' => 'true'); $i = 0; ?> <?php foreach ($tabs as $k => $v) { ?> <?php $newargs = $args; if ($k == 'best-sellers') { $newargs['meta_key'] = 'total_sales'; $newargs['orderby'] = 'meta_value_num'; } elseif ($k == 'on-sales') { $product_ids_on_sale = wc_get_product_ids_on_sale(); $newargs['post__in'] = array_merge(array(0), $product_ids_on_sale); $newargs['orderby'] = 'date'; $newargs['order'] = 'DESC'; } else { $newargs['orderby'] = 'date'; $newargs['order'] = 'DESC'; } $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $newargs, $atts)); if ($products->have_posts()) { if ($use_responsive) { $arr = array('0' => array("items" => $items_mobile), '768' => array("items" => $items_tablet), '992' => array("items" => $items_destop)); $data_responsive = json_encode($arr); $data_carousel["responsive"] = $data_responsive; if ($products->post_count < $items_mobile || $products->post_count < $items_tablet || $products->post_count < $items_destop) { $data_carousel['loop'] = 'false'; } else { $data_carousel['loop'] = $loop; } } else { if ($style == 3) { $data_carousel['items'] = 4; if ($products->post_count < 4) { $data_carousel['loop'] = 'false'; } else { $data_carousel['loop'] = $loop; } } else { $data_carousel['items'] = 3; if ($products->post_count < 3) { $data_carousel['loop'] = 'false'; } else { $data_carousel['loop'] = $loop; } } } $carousel = _data_carousel($data_carousel); ?> <!-- Style 1 --> <?php if ($style == 1) { ?> <div id="tab-<?php echo esc_attr($k) . $uniqeID; ?> " class="tab-panel <?php echo $i == 0 ? 'active' : ''; ?> "> <ul class="product-list owl-carousel" <?php echo apply_filters('kt_shortcode_tab_product_carousel', $carousel); ?> > <?php while ($products->have_posts()) { $products->the_post(); ?> <?php wc_get_template_part('content', 'product-tab'); ?> <?php } ?> </ul> </div> <!-- ./Style 1 --> <?php } ?> <!-- Style 2 --> <?php if ($style == 2) { ?> <div id="tab-<?php echo esc_attr($k) . $uniqeID; ?> " class="tab-panel <?php echo $i == 0 ? 'active' : ''; ?> "> <ul class="products-style8 columns-<?php echo esc_attr($columns); ?> "> <?php while ($products->have_posts()) { $products->the_post(); ?> <li class="product kt-template-loop"> <div class="product-container "> <div class="product-thumb"> <?php global $product; $attachment_ids = $product->get_gallery_attachment_ids(); $secondary_image = ''; if ($attachment_ids) { $secondary_image = wp_get_attachment_image($attachment_ids[0], $size); } if (has_post_thumbnail()) { ?> <a class="primary_image owl-lazy" href="<?php the_permalink(); ?> "><?php the_post_thumbnail($size); ?> </a> <?php } else { ?> <a class="primary_image owl-lazy" href="<?php the_permalink(); ?> "><?php echo wc_placeholder_img($size); ?> </a> <?php } if ($secondary_image != "") { ?> <a class="secondary_image owl-lazy" href="<?php the_permalink(); ?> "><?php echo $secondary_image; ?> </a> <?php } else { ?> <a class="secondary_image owl-lazy" href="<?php the_permalink(); ?> "><?php echo wc_placeholder_img($size); ?> </a> <?php } ?> <?php kt_get_tool_quickview(); ?> <div class="product-label"><?php do_action('kt_loop_product_label'); ?> </div> </div> <div class="product-info"> <div class="product-name"> <a href="<?php the_permalink(); ?> "> <?php the_title(); ?> </a> </div> <div class="box-price"> <?php do_action('kt_after_shop_loop_item_title'); ?> </div> <div class="button-control"> <?php kt_get_tool_compare(); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php kt_get_tool_wishlish(); ?> </div> </div> </div> </li> <?php } ?> </ul> </div> <?php } ?> <!-- ./Style 2 --> <!-- Style 3 --> <?php if ($style == 3) { ?> <div id="tab-<?php echo esc_attr($k) . $uniqeID; ?> " class="tab-panel <?php echo $i == 0 ? 'active' : ''; ?> "> <ul class="tab-products owl-carousel" <?php echo apply_filters('kt_shortcode_tab_product_carousel', $carousel); ?> > <?php while ($products->have_posts()) { $products->the_post(); ?> <li class="product-style3"> <?php wc_get_template_part('content', 'product-style3'); ?> </li> <?php } ?> </ul> </div> <?php } ?> <!-- ./Style 3 --> <?php } ?> <?php wp_reset_query(); wp_reset_postdata(); $i++; ?> <?php } ?> </div> </div> <?php remove_filter('kt_product_thumbnail_loop', array(&$this, 'get_size_product')); return ob_get_clean(); }
function venedor_woocommerce_thumbnail() { global $product, $woocommerce, $venedor_settings; $id = get_the_ID(); $size = 'shop_catalog'; $gallery = get_post_meta($id, '_product_image_gallery', true); $attachment_image = ''; if ($venedor_settings['category-image-effect'] && !empty($gallery)) { $gallery = explode(',', $gallery); $first_image_id = $gallery[0]; $attachment_image = wp_get_attachment_image($first_image_id, $size, false, array('class' => 'hover-image')); } $thumb_image = get_the_post_thumbnail($id, $size); $class = "product-image"; if (!$thumb_image) { if (wc_placeholder_img_src()) { $thumb_image = wc_placeholder_img($size); } } if (!$attachment_image || !$venedor_settings['category-image-effect']) { $class = "product-image no-image"; } echo '<span class="' . $class . '">'; // show images echo $attachment_image; echo $thumb_image; // show hot/sale label woocommerce_show_product_loop_sale_flash(); // show price if ($venedor_settings['product-price']) { if ($product->get_price() != '') { $variable_class = ''; if ($product->is_type(array('variable')) && $product->get_variation_price('min') !== $product->get_variation_price('max')) { $variable_class = ' price-variable'; } if ($product->is_type(array('grouped'))) { $child_prices = array(); foreach ($product->get_children() as $child_id) { $child_prices[] = get_post_meta($child_id, '_price', true); } $child_prices = array_unique($child_prices); if (!empty($child_prices)) { $variable_class = ' price-variable'; } } echo '<div class="price-box ' . $venedor_settings['product-price-pos'] . $variable_class . '">'; woocommerce_template_loop_price(); echo '</div>'; } } // show quick view if ($venedor_settings['category-quickview']) { ?> <div class="figcaption<?php if (!$venedor_settings['category-hover']) { echo ' no-hover'; } ?> "> <span class="btn btn-arrow quickview-button <?php echo $venedor_settings['category-quickview-pos']; ?> " data-id="<?php echo the_ID(); ?> "><span class="fa fa-search"></span></span> </div> <?php } echo '</span>'; }
/** * Alter the cart item thumbnail size * * @since 3.0.0 */ public static function cart_item_thumbnail($thumb, $cart_item, $cart_item_key) { if (!empty($cart_item['variation_id']) && ($thumbnail = get_post_thumbnail_id($cart_item['variation_id']))) { return wpex_get_post_thumbnail(array('size' => 'shop_thumbnail', 'attachment' => $thumbnail)); } elseif (isset($cart_item['product_id']) && ($thumbnail = get_post_thumbnail_id($cart_item['product_id']))) { return wpex_get_post_thumbnail(array('size' => 'shop_thumbnail', 'attachment' => $thumbnail)); } else { return wc_placeholder_img(); } }
?> " title="<?php echo esc_attr($product->get_title()); ?> "> <?php if (has_post_thumbnail($product->id)) { ?> <?php wpex_post_thumbnail(array('size' => 'shop_thumbnail')); ?> <?php } else { ?> <?php echo wc_placeholder_img(); ?> <?php } ?> <span class="product-title"><?php echo $product->get_title(); ?> </span> </a> <?php if (!empty($show_rating)) { echo $product->get_rating_html(); } ?> <?php
/** * @deprecated */ function woocommerce_placeholder_img($size = 'shop_thumbnail') { return wc_placeholder_img($size); }
public function get_contents($order, $package) { $totals = 0; foreach ($package->packed as $key => $item) { $item_ids[] = $item['meta']['id']; } $items = $order->get_items(); $counts = array_count_values($item_ids); foreach ($counts as $key => $qty) { $product = wc_get_product($key); $parent = wc_get_product($product->parent->post->ID); $item = get_post_meta($key); $price = $product->price; $total = $price * $qty; $totals += $total; ?> <tr> <td class="slp_thumb"><?php if ($product) { ?> <a href="<?php echo esc_url(admin_url('post.php?post=' . absint($product->id) . '&action=edit')); ?> " class="tips" data-tip="<?php echo '<strong>' . __('Product ID:', 'slp') . '</strong> ' . absint($product->id); if ($product->variation_id && 'product_variation' === get_post_type($product->variation_id)) { echo '<br/><strong>' . __('Variation ID:', 'slp') . '</strong> ' . absint($product->variation_id); } elseif ($product->variation_id) { echo '<br/><strong>' . __('Variation ID:', 'slp') . '</strong> ' . absint($product->variation_id) . ' (' . __('No longer exists', 'slp') . ')'; } if ($product && $product->get_sku()) { echo '<br/><strong>' . __('Product SKU:', 'slp') . '</strong> ' . esc_html($product->get_sku()); } if ($product && isset($product->variation_data)) { echo '<br/>' . wc_get_formatted_variation($product->variation_data, true); } ?> "> <?php echo $product->get_image('shop_thumbnail', array('title' => '')); ?> </a><?php } else { echo wc_placeholder_img('shop_thumbnail'); } ?> <td><a href="<?php echo admin_url("post.php?post={$product->id}&action=edit"); ?> "><?php echo $product->sku ? $product->sku . ' - ' . $product->post->post_title : $product->post->post_title; ?> </a></td> <td><?php echo $qty; ?> </td> <td style="text-align:right;"><?php echo wc_price($price); ?> </td> <td style="text-align:right;"><?php echo wc_price($total); ?> </td> </tr><?php } ?> <tr> <td colspan="4" style="border-top:1px solid #999; text-align:right;"><?php _e('Package Value', 'slp'); ?> </td> <td style="border-top:1px solid #999; text-align:right;"><?php echo wc_price($totals); ?> </td> </tr> <tr/><?php }
} ?> <div class="grid-item<?php echo $product->is_on_sale() ? ' sale' : ''; echo $classes; ?> "> <?php $thumbnal_id = get_post_thumbnail_id($product->id); $img = wp_get_attachment_image_src($thumbnal_id, 'shop_catalog', true); echo '<a class="product-image" href="' . get_permalink($product->id) . '">'; woocommerce_show_product_loop_sale_flash(); if (has_post_thumbnail($product->id)) { echo '<img src="' . placeImg($img[1], $img[2]) . '" alt="' . get_alt($thumbnal_id) . '" data-defer="' . $img[0] . '" class="aligncenter" width="' . $img[1] . '" height="' . $img[2] . '" />'; } else { echo wc_placeholder_img('shop_catalog'); } echo '</a>'; ?> <div class="product-data"> <a class="product-title" href="<?php the_permalink(); ?> "> <h3><?php echo get_the_title($product->id); ?> </h3> <div class="product-price"><?php echo $product->get_price_html(); ?>
function dp_get_image_box($dp_image) { global $product; if (has_post_thumbnail()) { $result .= '<div class="dp-img-wrapper hideableHover">'; $image = wp_get_attachment_image_src(get_post_thumbnail_id($r->post->ID), 'full'); if ($image) { $params = array('width' => $dp_image['width'], 'height' => $dp_image['height'], 'crop' => $dp_image['crop']); $result .= '<img src="' . bfi_thumb($image[0], $params) . '" alt="" />'; } $result .= '</div>'; } else { $result .= wc_placeholder_img(); } return $result; }
if ($_product && $_product->get_sku()) { echo '<br/><strong>' . __('Product SKU:', 'woocommerce') . '</strong> ' . esc_html($_product->get_sku()); } if ($_product && isset($_product->variation_data)) { echo '<br/>' . wc_get_formatted_variation($_product->variation_data, true); } ?> "><?php echo $_product->get_image('shop_thumbnail', array('title' => '')); ?> </a> <?php } else { ?> <?php echo wc_placeholder_img('shop_thumbnail'); ?> <?php } ?> </td> <td class="name"> <?php echo $_product && $_product->get_sku() ? esc_html($_product->get_sku()) . ' – ' : ''; ?> <?php if ($_product) { ?> <a target="_blank" href="<?php
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { global $woocommerce; $cache = wp_cache_get('widget_best_sellers', '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']) ? __('Best Sellers', 'yit') : $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; } } } $query_args = array('posts_per_page' => $number, 'post_status' => 'publish', 'post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'no_found_rows' => 1); $query_args['meta_query'] = array(); if (isset($instance['hide_free']) && 1 == $instance['hide_free']) { $query_args['meta_query'][] = array('key' => '_price', 'value' => 0, 'compare' => '>', 'type' => 'DECIMAL'); } $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $query_args['meta_query'][] = $woocommerce->query->visibility_meta_query(); $r = new WP_Query($query_args); if ($r->have_posts()) { echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo '<div class="clear"></div>'; echo '<ul class="product_list_widget">'; $number = 1; while ($r->have_posts()) { $r->the_post(); global $product; if (function_exists('wc_placeholder_img')) { echo '<li> <a href="' . get_permalink() . '"> ' . (has_post_thumbnail() ? get_the_post_thumbnail($r->post->ID, 'shop_thumbnail') : wc_placeholder_img('shop_thumbnail')) . ' ' . get_the_title() . ' </a> ' . $product->get_price_html() . ' </li>'; } else { 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>'; } $number++; } echo '</ul>'; echo $after_widget; } $content = ob_get_clean(); if (isset($args['widget_id'])) { $cache[$args['widget_id']] = $content; } echo $content; wp_cache_set('widget_best_sellers', $cache, 'widget'); }