本文整理汇总了PHP中woocommerce_reset_loop函数的典型用法代码示例。如果您正苦于以下问题:PHP woocommerce_reset_loop函数的具体用法?PHP woocommerce_reset_loop怎么用?PHP woocommerce_reset_loop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了woocommerce_reset_loop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wb_products
function wb_products($atts, $before, $after)
{
global $woocommerce_loop;
$atts = shortcode_atts(array('number' => null, 'orderby' => 'name', 'order' => 'ASC', 'columns' => '4', 'hide_empty' => 1, 'parent' => '', 'ids' => ''), $atts);
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_categories = get_terms('product_cat', $args);
if ('' !== $atts['parent']) {
$product_categories = wp_list_filter($product_categories, array('parent' => $atts['parent']));
}
if ($hide_empty) {
foreach ($product_categories as $key => $category) {
if ($category->count == 0) {
unset($product_categories[$key]);
}
}
}
if ($atts['number']) {
$product_categories = array_slice($product_categories, 0, $atts['number']);
}
$columns = absint($atts['columns']);
$woocommerce_loop['columns'] = $columns;
ob_start();
// Reset loop/columns globals when starting a new loop
$woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
if ($product_categories) {
echo $before;
foreach ($product_categories as $category) {
wc_get_template('content-product_cat.php', array('category' => $category));
}
echo $after;
}
woocommerce_reset_loop();
return ob_get_clean();
}
示例2: product_categories
/**
* List all (or limited) product categories
*
* @param array $atts
* @return string
*/
public static function product_categories($atts)
{
global $woocommerce_loop;
$atts = shortcode_atts(array('number' => null, 'orderby' => 'name', 'order' => 'ASC', 'columns' => '4', 'hide_empty' => 1, 'product_tag' => '', 'parent' => '', 'ids' => ''), $atts);
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_tag' => $atts['product_tag']);
$product_categories = get_terms('product_cat', $args);
$product_tags = get_terms('product_tag', $args);
if ('' !== $atts['parent']) {
$product_categories = wp_list_filter($product_categories, array('parent' => $atts['parent']));
}
foreach ($product_tags as $key => $category) {
if ($category->slug == $atts['product_tag']) {
// echo "<script>console.log( 'Debug Objects: " .json_encode($category) . "' );</script>";
}
}
if ($hide_empty) {
foreach ($product_categories as $key => $category) {
if ($category->count == 0) {
unset($product_categories[$key]);
}
}
}
if ($atts['number']) {
$product_categories = array_slice($product_categories, 0, $atts['number']);
}
$woocommerce_loop['columns'] = $atts['columns'];
ob_start();
// Reset loop/columns globals when starting a new loop
$woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
if ($product_categories) {
woocommerce_product_loop_start();
foreach ($product_categories as $category) {
wc_get_template('content-product_cat.php', array('category' => $category));
echo "<script>console.log( 'Debug Objects: " . json_encode($category) . "' );</script>";
}
woocommerce_product_loop_end();
}
woocommerce_reset_loop();
return '<div class="woocommerce columns-' . $atts['columns'] . '">' . ob_get_clean() . '</div>';
}
示例3: product_lookbook_shortcode
public function product_lookbook_shortcode($atts, $content = null)
{
global $woocommerce_loop;
$atts = shortcode_atts(array('number' => null, 'orderby' => 'name', 'order' => 'ASC', 'columns' => '4', 'hide_empty' => 1, 'parent' => '', 'ids' => ''), $atts);
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('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']);
}
$woocommerce_loop['columns'] = $atts['columns'];
ob_start();
// Reset loop/columns globals when starting a new loop
$woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
if ($product_brands) {
woocommerce_product_loop_start();
foreach ($product_brands as $brand) {
wc_get_template('content-product_brand.php', array('brand' => $brand));
}
woocommerce_product_loop_end();
}
woocommerce_reset_loop();
return '<div class="woocommerce columns-' . $atts['columns'] . '">' . ob_get_clean() . '</div>';
}
示例4: product_categories
/**
* List all (or limited) product categories.
*
* @param array $atts
* @return string
*/
public static function product_categories($atts)
{
global $woocommerce_loop;
$atts = shortcode_atts(array('number' => null, 'orderby' => 'name', 'order' => 'ASC', 'columns' => '4', 'hide_empty' => 1, 'parent' => '', 'ids' => ''), $atts);
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_categories = get_terms('product_cat', $args);
if ('' !== $atts['parent']) {
$product_categories = wp_list_filter($product_categories, array('parent' => $atts['parent']));
}
if ($hide_empty) {
foreach ($product_categories as $key => $category) {
if ($category->count == 0) {
unset($product_categories[$key]);
}
}
}
if ($atts['number']) {
$product_categories = array_slice($product_categories, 0, $atts['number']);
}
$columns = absint($atts['columns']);
$woocommerce_loop['columns'] = $columns;
ob_start();
if ($product_categories) {
woocommerce_product_loop_start();
foreach ($product_categories as $category) {
wc_get_template('content-product_cat.php', array('category' => $category));
}
woocommerce_product_loop_end();
}
woocommerce_reset_loop();
return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}
示例5: mr_tailor_product_categories_einhornified
function mr_tailor_product_categories_einhornified($atts)
{
extract(shortcode_atts(array('number' => null, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'parent' => ''), $atts));
if (isset($atts['ids'])) {
$ids = explode(',', $atts['ids']);
$ids = array_map('trim', $ids);
} else {
$ids = array();
}
$hide_empty = $hide_empty == true || $hide_empty == 1 ? 1 : 0;
// get terms and workaround WP bug with parents/pad counts
$args = array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $parent);
$product_categories = get_terms('product_cat', $args);
if ($parent !== "") {
$product_categories = wp_list_filter($product_categories, array('parent' => $parent));
}
if ($hide_empty) {
foreach ($product_categories as $key => $category) {
if ($category->count == 0) {
unset($product_categories[$key]);
}
}
}
if ($number) {
$product_categories = array_slice($product_categories, 0, $number);
}
ob_start();
$cat_counter = 0;
$cat_number = count($product_categories);
if ($product_categories) {
foreach ($product_categories as $category) {
$thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($thumbnail_id);
$cat_class = "";
$cat_counter++;
switch ($cat_number) {
case 1:
$cat_class = "one_cat_" . $cat_counter;
break;
case 2:
$cat_class = "two_cat_" . $cat_counter;
break;
case 3:
$cat_class = "three_cat_" . $cat_counter;
break;
case 4:
$cat_class = "four_cat_" . $cat_counter;
break;
case 5:
$cat_class = "five_cat_" . $cat_counter;
break;
default:
if ($cat_counter < 7) {
$cat_class = $cat_counter;
} else {
$cat_class = "more_than_6";
}
}
?>
<div class="category_<?php
echo $cat_class;
?>
">
<div class="category_grid_box">
<span class="category_item_bkg" style="background-image:url(<?php
echo $image;
?>
)"></span>
<a href="<?php
echo get_term_link($category->slug, 'product_cat');
?>
" class="category_item" >
<span class="category_name"><?php
// echo $category->name;
?>
</span>
</a>
</div>
</div>
<?php
}
?>
<div class="clearfix"></div>
<?php
}
woocommerce_reset_loop();
return '<div class="row"><div class="categories_grid test">' . ob_get_clean() . '</div></div>';
}
示例6: etheme_product_categories
function etheme_product_categories($atts)
{
global $woocommerce_loop;
extract(shortcode_atts(array('number' => null, 'title' => '', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'parent' => '', 'display_type' => 'grid', 'class' => ''), $atts));
if (isset($atts['ids'])) {
$ids = explode(',', $atts['ids']);
$ids = array_map('trim', $ids);
} else {
$ids = array();
}
$title_output = '';
if ($title != '') {
$title_output = '<h3 class="title"><span>' . $title . '</span></h3>';
}
$hide_empty = $hide_empty == true || $hide_empty == 1 ? 1 : 0;
// get terms and workaround WP bug with parents/pad counts
$args = array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $parent);
$product_categories = get_terms('product_cat', $args);
if ($parent !== "") {
$product_categories = wp_list_filter($product_categories, array('parent' => $parent));
}
if ($hide_empty) {
foreach ($product_categories as $key => $category) {
if ($category->count == 0) {
unset($product_categories[$key]);
}
}
}
if ($number) {
$product_categories = array_slice($product_categories, 0, $number);
}
//$woocommerce_loop['columns'] = $columns;
if ($display_type == 'slider') {
$class .= 'owl-carousel carousel-area';
} else {
$class .= 'row';
}
$box_id = rand(1000, 10000);
ob_start();
// Reset loop/columns globals when starting a new loop
$woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
$woocommerce_loop['display_type'] = $display_type;
if ($product_categories) {
if ($display_type == 'menu') {
$instance = array('title' => $title, 'hierarchical' => 1, 'orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $parent);
$args = array();
the_widget('WC_Widget_Product_Categories', $instance, $args);
} else {
echo $title_output;
echo '<div class="categoriesCarousel ' . $class . ' slider-' . $box_id . '">';
foreach ($product_categories as $category) {
wc_get_template('content-product_cat.php', array('category' => $category));
}
echo '</div>';
}
if ($display_type == 'slider') {
echo '
<script type="text/javascript">
jQuery(".slider-' . $box_id . '").owlCarousel({
items:4,
lazyLoad : true,
navigation: true,
navigationText:false,
rewindNav: false,
itemsCustom: [[0, 1], [479,2], [619,3], [768,3], [1200, 4], [1600, 4]]
});
</script>
';
}
}
woocommerce_reset_loop();
return ob_get_clean();
}
示例7: ux_product_categories_grid
//.........这里部分代码省略.........
echo $padding;
?>
!important}
#banner_grid_<?php
echo $bannergridID;
?>
.ux_banner-grid .columns > .column-inner{padding-left: <?php
echo $padding_w;
?>
px !important; padding-right: <?php
echo $padding_w;
?>
px !important;}
</style>
<?php
}
?>
<div id="banner_grid_<?php
echo $bannergridID;
?>
">
<div class="row">
<div class="large-12 columns">
<div class="row collapse ux_banner-grid ux_banner-grid-new">
<?php
/**
* Check if WooCommerce is active
**/
if (function_exists('wc_print_notices')) {
?>
<?php
if ($product_categories) {
foreach ($product_categories as $category) {
global $woocommerce_loop;
// Store loop count we're currently on
if (empty($woocommerce_loop['loop'])) {
$woocommerce_loop['loop'] = 0;
}
// Increase loop count
$woocommerce_loop['loop']++;
if ($woocommerce_loop['loop'] < $g_total) {
$cat_span = $g['span' . $woocommerce_loop['loop']];
$cat_height = $g['height' . $woocommerce_loop['loop']];
} else {
$cat_span = $g['span' . $g_total];
$cat_height = $g['height' . $g_total];
}
$idcat = $category->woocommerce_term_id;
$thumbnail_id = get_woocommerce_term_meta($idcat, 'thumbnail_id', true);
$image = wp_get_attachment_image_src($thumbnail_id, 'large');
$image = $image[0];
if ($category->count > 0) {
$cat_count = apply_filters('woocommerce_subcategory_count_html', ' <span class="count">' . $category->count . ' ' . __('Products', 'woocommerce') . '</span>', $category);
}
$cat_link = get_term_link($category->slug, 'product_cat');
?>
<div class="columns ux-grid-column <?php
echo $cat_span;
?>
" style="height:<?php
echo $cat_height;
?>
">
<div class="column-inner cat-banner">
<?php
echo fixShortcode('
[ux_banner bg_overlay="' . $bg_overlay . '" link="' . $cat_link . '" hover="fade" text_color="light" bg="' . $image . '" tx_color="dark" animate="none" tx_width="60%"]
<h2 class="uppercase cat-title">' . $category->name . '</h2><p class="cat-count hide-for-small lead uppercase">' . $cat_count . '</p>
[/ux_banner]');
?>
</div><!-- .column-inner -->
</div><!-- .columns --> <?php
}
}
woocommerce_reset_loop();
?>
<?php
}
?>
</div>
</div>
</div>
<script>
jQuery(document).ready(function ($) {
var $container = $("#banner_grid_<?php
echo $bannergridID;
?>
.ux_banner-grid");
$container.packery({
itemSelector: ".columns",
gutter: 0
});
});
</script>
</div><!-- #grid -->
<?php
$content = ob_get_contents();
ob_end_clean();
return $content;
}
示例8: product_categories
/**
* List all (or limited) product categories
*
* @access public
* @param array $atts
* @return string
*/
public static function product_categories($atts)
{
global $woocommerce_loop;
extract(shortcode_atts(array('number' => null, 'orderby' => 'name', 'order' => 'ASC', 'columns' => '4', 'hide_empty' => 1, 'parent' => ''), $atts));
if (isset($atts['ids'])) {
$ids = explode(',', $atts['ids']);
$ids = array_map('trim', $ids);
} else {
$ids = array();
}
$hide_empty = $hide_empty == true || $hide_empty == 1 ? 1 : 0;
// get terms and workaround WP bug with parents/pad counts
$args = array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $parent);
$product_categories = get_terms('product_cat', $args);
if ($parent !== "") {
$product_categories = wp_list_filter($product_categories, array('parent' => $parent));
}
if ($number) {
$product_categories = array_slice($product_categories, 0, $number);
}
$woocommerce_loop['columns'] = $columns;
ob_start();
// Reset loop/columns globals when starting a new loop
$woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
if ($product_categories) {
woocommerce_product_loop_start();
foreach ($product_categories as $category) {
wc_get_template('content-product_cat.php', array('category' => $category));
}
woocommerce_product_loop_end();
}
woocommerce_reset_loop();
return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}
示例9: vc_woo_carousel_product_category_func
function vc_woo_carousel_product_category_func($atts, $content = null)
{
extract(shortcode_atts(array('per_page' => '12', 'columns' => '', 'orderby' => '', 'order' => '', 'category' => '', 'operator' => 'IN', 'carousel_autoheight' => '', 'carousel_margin' => '', 'carousel_navi' => '', 'carousel_dots_navi' => '', 'carousel_autoplay' => '', 'carousel_autoplaytimeout' => '', 'carousel_autoplayhoverpause' => '', 'carousel_loop' => ''), $atts));
if (empty($columns)) {
$columns = '2';
}
if (empty($orderby)) {
$orderby = 'date';
}
if (empty($order)) {
$order = 'DESC';
}
global $woocommerce_loop;
if (!$category) {
return '';
}
// Default ordering args
$ordering_args = WC()->query->get_catalog_ordering_args($orderby, $order);
$args = array('post_type' => 'product', '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' => $operator)));
if (isset($ordering_args['meta_key'])) {
$args['meta_key'] = $ordering_args['meta_key'];
}
global $shortcode_atts;
$shortcode_atts = array('carousel_autoheight' => $carousel_autoheight, 'carousel_margin' => $carousel_margin, 'carousel_navi' => $carousel_navi, 'carousel_dots_navi' => $carousel_dots_navi, 'carousel_autoplay' => $carousel_autoplay, 'carousel_autoplaytimeout' => $carousel_autoplaytimeout, 'carousel_autoplayhoverpause' => $carousel_autoplayhoverpause, 'carousel_loop' => $carousel_loop, 'columns' => $columns);
lpd_owl_carousel();
global $carousel_product_category_ID;
$carousel_product_category_ID = rand();
ob_start();
?>
<?php
$products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
$woocommerce_loop['columns'] = $columns;
if ($products->have_posts()) {
?>
<div class="row">
<ul class="lpd-products owl-carousel-<?php
echo esc_attr($carousel_product_category_ID);
?>
">
<?php
while ($products->have_posts()) {
$products->the_post();
?>
<?php
wc_get_template_part('content', 'product');
?>
<?php
}
// end of the loop.
?>
</ul></div>
<?php
}
?>
<?php
$counter_js = new carousel_product_category_class();
$counter_js->carousel_product_category_callback();
?>
<?php
woocommerce_reset_loop();
wp_reset_postdata();
return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}
示例10: content
//.........这里部分代码省略.........
$heading_subtitle = '';
if ($subtitle) {
$atts['font_container'] = $atts['font_container_subtitle'];
$atts['google_fonts'] = '';
$style_subtitle = $this->getCustomStyle($atts);
if (!empty($style_subtitle['style'])) {
$style_subtitle_css = 'style="' . esc_attr(implode(';', $style_subtitle['style'])) . '"';
}
$heading_subtitle = '<div class="kt-heading-subtitle" ' . $style_subtitle_css . '>' . $subtitle . '</div>';
}
$heading_backend = '';
if ($backend) {
$atts['font_container'] = $atts['font_container_backend'];
$atts['google_fonts'] = '';
$style_backend = $this->getCustomStyle($atts);
if (!empty($style_backend['style'])) {
$style_backend_css = 'style="' . esc_attr(implode(';', $style_backend['style'])) . '"';
}
$heading_backend = '<div class="kt-heading-backend" ' . $style_backend_css . '>' . $backend . '</div>';
}
$heading .= $heading_backend . $heading_title . $heading_subtitle;
$elementClassHeading = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClassHeading));
$heading = '<div class="' . esc_attr($elementClassHeading) . '">' . $heading . '</div>';
}
$uniqeID = uniqid();
$meta_query = WC()->query->get_meta_query();
$args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $atts['per_page'], 'meta_query' => $meta_query);
$tabs = array();
if ($source == 'categories') {
$tabs = explode(',', $categories);
$args['order'] = $order;
$args['orderby'] = $orderby;
} else {
$tabs = array('featured', 'new', 'bestselling');
}
$tab_heading = '<ul class="nav nav-style-' . $nav . '" data-count="' . count($tabs) . '">';
$i = 1;
foreach ($tabs as $tab) {
if ($source == 'categories') {
$term = get_term_by('slug', sanitize_title($tab), 'product_cat');
$text = $term->name;
} else {
if ($tab == 'featured') {
$text = esc_html__('Hot Products', 'wingman');
} elseif ($tab == 'new') {
$text = esc_html__('New Arrivals', 'wingman');
} elseif ($tab == 'bestselling') {
$text = esc_html__('Best Sellers', 'wingman');
}
}
$class = $active_section == $i ? ' class="active"' : '';
$tab_heading .= sprintf('<li %s><a href="%s" data-toggle="tab"><span data-hover="%s">%s</span></a></li>', $class, '#tab-' . $tab . '-' . $uniqeID, esc_attr($text), $text);
$i++;
}
$tab_heading .= "</ul>";
global $woocommerce_loop;
$i = 1;
$output_content = '';
foreach ($tabs as $tab) {
$new_args = $args;
if ($source == 'categories') {
$new_args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => sanitize_title($tab), 'field' => 'slug', 'operator' => $atts['operator']));
} else {
if ($tab == 'bestselling') {
$new_args['meta_key'] = 'total_sales';
$new_args['orderby'] = 'meta_value_num';
} elseif ($tab == 'featured') {
$new_args['meta_query'][] = array('key' => '_featured', 'value' => 'yes');
}
}
$products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $new_args, $atts));
$woocommerce_loop['columns'] = $atts['columns'];
$woocommerce_loop['effect'] = $atts['hover_effect'];
ob_start();
if ($products->have_posts()) {
if ($products_layout == 'carousel') {
echo sprintf('<div class="owl-carousel-kt"><div class="wc-carousel-wrapper" data-options=\'{"desktop": "%s","desktopsmall": "%s","tablet": "%s","mobile": "1","navigation": true, "pagination": false}\'>', $product_columns, $product_columns_desktop, $product_columns_tablet);
}
woocommerce_product_loop_start();
while ($products->have_posts()) {
$products->the_post();
wc_get_template_part('content', 'product');
}
// end of the loop.
woocommerce_product_loop_end();
if ($products_layout == 'carousel') {
echo '</div></div>';
}
}
woocommerce_reset_loop();
wp_reset_postdata();
$class = $active_section == $i ? 'fade in active' : '';
$output_content .= sprintf('<div id="%s" class="tab-pane %s">%s</div><!-- .tab-pane -->', 'tab-' . $tab . '-' . $uniqeID, $class, ob_get_clean());
$i++;
}
$output = sprintf('<div class="wc-products-tab-heading">%s</div><div class="tab-content">%s</div>', $heading . $tab_heading, $output_content);
$elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
$output = '<div class="' . esc_attr($elementClass) . '"><div class="woocommerce columns-' . $atts['columns'] . '">' . $output . '</div></div>';
return $output;
}
示例11: vc_woo_carousel_product_categories_func
function vc_woo_carousel_product_categories_func($atts, $content = null)
{
extract(shortcode_atts(array('number' => null, 'orderby' => '', 'order' => '', 'columns' => '', 'hide_empty' => '', 'parent' => '', 'carousel_autoheight' => '', 'carousel_margin' => '', 'carousel_navi' => '', 'carousel_dots_navi' => '', 'carousel_autoplay' => '', 'carousel_autoplaytimeout' => '', 'carousel_autoplayhoverpause' => '', 'carousel_loop' => ''), $atts));
if (empty($columns)) {
$columns = '2';
}
if (empty($orderby)) {
$orderby = 'date';
}
if (empty($order)) {
$order = 'DESC';
}
if (empty($hide_empty)) {
$hide_empty = '1';
}
global $woocommerce_loop;
if (isset($atts['ids'])) {
$ids = explode(',', $atts['ids']);
$ids = array_map('trim', $ids);
} else {
$ids = array();
}
$hide_empty = $hide_empty == true || $hide_empty == 1 ? 1 : 0;
// get terms and workaround WP bug with parents/pad counts
$args = array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $parent);
$product_categories = get_terms('product_cat', $args);
if ($parent !== "") {
$product_categories = wp_list_filter($product_categories, array('parent' => $parent));
}
if ($hide_empty) {
foreach ($product_categories as $key => $category) {
if ($category->count == 0) {
unset($product_categories[$key]);
}
}
}
if ($number) {
$product_categories = array_slice($product_categories, 0, $number);
}
$woocommerce_loop['columns'] = $columns;
global $shortcode_atts;
$shortcode_atts = array('carousel_autoheight' => $carousel_autoheight, 'carousel_margin' => $carousel_margin, 'carousel_navi' => $carousel_navi, 'carousel_dots_navi' => $carousel_dots_navi, 'carousel_autoplay' => $carousel_autoplay, 'carousel_autoplaytimeout' => $carousel_autoplaytimeout, 'carousel_autoplayhoverpause' => $carousel_autoplayhoverpause, 'carousel_loop' => $carousel_loop, 'columns' => $columns);
lpd_owl_carousel();
global $carousel_product_categories_ID;
$carousel_product_categories_ID = rand();
ob_start();
?>
<?php
// Reset loop/columns globals when starting a new loop
$woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
if ($product_categories) {
?>
<div class="row"><ul class="lpd-products owl-carousel-<?php
echo esc_attr($carousel_product_categories_ID);
?>
">
<?php
foreach ($product_categories as $category) {
wc_get_template('content-product_cat.php', array('category' => $category));
}
?>
</ul></div>
<?php
}
$counter_js = new carousel_product_categories_class();
$counter_js->carousel_product_categories_callback();
woocommerce_reset_loop();
return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}
示例12: thb_grid
//.........这里部分代码省略.........
<?php
$small_thumbnail_size = apply_filters('single_product_small_thumbnail_size', 'shop_catalog');
$thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
if ($thumbnail_id) {
$image = wp_get_attachment_image_src($thumbnail_id, 'full');
$image_src = $image[0];
$image = aq_resize($image_src, $imagesize[0], $imagesize[1], true, true, true);
} else {
$image = wc_placeholder_img_src();
}
if ($image_src) {
echo '<img src="' . $image . '" alt="' . esc_attr($category->name) . '" width="' . $imagesize[0] . '" height="' . $imagesize[1] . '" />';
}
?>
<div class="title">
<h2><?php
echo $category->name;
if ($category->count > 0) {
echo apply_filters('woocommerce_subcategory_count_html', ' <span class="count">(' . $category->count . ')</span>', $category);
}
?>
</h2>
</div>
</a>
</article>
<?php
$i++;
}
?>
</div>
<?php
}
woocommerce_reset_loop();
?>
<?php
} else {
?>
<?php
$product_id_array = explode(',', $product_ids);
$args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'post__in' => $product_id_array, 'posts_per_page' => "-1");
$products = new WP_Query($args);
if ($products->have_posts()) {
?>
<div class="grid products"> <?php
while ($products->have_posts()) {
$products->the_post();
if ($style == "style1") {
switch ($i) {
case 1:
case 6:
case 11:
case 16:
$imagesize = array("1440", "800");
$articlesize = 'small-12 medium-8';
break;
case 2:
case 7:
case 12:
case 17:
$imagesize = array("720", "406");
$articlesize = 'small-12 medium-4 grid-sizer';
break;
case 4:
示例13: shortcode_mc_6_1_products_grid
function shortcode_mc_6_1_products_grid($atts)
{
global $grid_products, $grid_product_details;
extract(shortcode_atts(array('title' => '', 'shortcode_name' => '', 'ids' => '', 'skus' => '', 'category' => '', 'orderby' => '', 'order' => 'desc', 'per_page' => '7', 'el_class' => ''), $atts));
$shortcode_attributes = array();
$per_page = 7;
switch ($shortcode_name) {
case 'products_ids':
$shortcode_attributes['ids'] = $ids;
$shortcode_name = 'products';
break;
case 'products_skus':
$shortcode_attributes['skus'] = $skus;
$shortcode_attributes['columns'] = $columns;
$shortcode_name = 'products';
break;
case 'product_category':
$shortcode_attributes['category'] = $category;
$shortcode_attributes['per_page'] = $per_page;
break;
case 'recent_products':
case 'featured_products':
case 'best_selling_products':
case 'sale_products':
case 'top_rated_products':
$shortcode_attributes['per_page'] = $per_page;
break;
}
if ($shortcode_name != 'best_selling_products') {
$shortcode_attributes['orderby'] = $orderby;
$shortcode_attributes['order'] = $order;
}
$grid_products = MC_6_1_Products_Grid::get_products($shortcode_name, $shortcode_attributes);
$grid_product_details['title'] = $title;
$grid_product_details['el_class'] = $el_class;
$grid_product_details['grid_id'] = sanitize_title($title);
$plugin_dir = dirname(MC_VC_PLUGIN_FILE_PATH);
include $plugin_dir . '/templates/products-grid/mc_6_1_products_grid.php';
woocommerce_reset_loop();
wp_reset_postdata();
}
示例14: rt_product_category_shortcode
function rt_product_category_shortcode($atts)
{
global $woocommerce_loop, $page_product_count;
if (empty($atts)) {
return '';
}
extract(shortcode_atts(array('per_page' => '12', 'columns' => '4', 'orderby' => 'title', 'order' => 'desc', 'category' => '', 'operator' => 'IN'), $atts));
if (!$category) {
return '';
}
// Default ordering args
$ordering_args = WC()->query->get_catalog_ordering_args($orderby, $order);
$args = array('post_type' => 'product', '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' => $operator)));
if (isset($ordering_args['meta_key'])) {
$args['meta_key'] = $ordering_args['meta_key'];
}
ob_start();
$products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
//get product counts
$page_product_count = $products->post_count;
$woocommerce_loop['columns'] = $columns;
if ($products->have_posts()) {
?>
<?php
woocommerce_product_loop_start();
?>
<?php
while ($products->have_posts()) {
$products->the_post();
?>
<?php
wc_get_template_part('content', 'product');
?>
<?php
}
// end of the loop.
?>
<?php
woocommerce_product_loop_end();
?>
<?php
}
woocommerce_reset_loop();
wp_reset_postdata();
return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}
示例15: ux_product_categories_grid
function ux_product_categories_grid($atts, $content = null)
{
extract(shortcode_atts(array('number' => null, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'parent' => '', 'hover' => '', 'description' => '', 'height' => '', 'parallax' => ''), $atts));
if (isset($atts['ids'])) {
$ids = explode(',', $atts['ids']);
$ids = array_map('trim', $ids);
} else {
$ids = array();
}
$hide_empty = $hide_empty == true || $hide_empty == 1 ? 1 : 0;
// get terms and workaround WP bug with parents/pad counts
$args = array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $parent);
$product_categories = get_terms('product_cat', $args);
if ($parent !== "") {
$product_categories = wp_list_filter($product_categories, array('parent' => $parent));
}
if ($number) {
$product_categories = array_slice($product_categories, 0, $number);
}
ob_start();
?>
<div class="row">
<?php
/**
* Check if WooCommerce is active
**/
if (function_exists('wc_print_notices')) {
?>
<?php
if ($product_categories) {
foreach ($product_categories as $category) {
woocommerce_get_template('content-product_cat_featured.php', array('category' => $category));
}
}
woocommerce_reset_loop();
?>
<?php
}
?>
</div>
<?php
$content = ob_get_contents();
ob_end_clean();
return $content;
}