本文整理汇总了PHP中wc_get_template_part函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_template_part函数的具体用法?PHP wc_get_template_part怎么用?PHP wc_get_template_part使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_get_template_part函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
public function widget($args, $instance)
{
extract($args);
extract($instance);
$title = apply_filters('widget_title', $title);
echo $before_widget;
echo $before_title . $title . $after_title;
$loop = pgl_woocommerce_query('deals', 1);
?>
<div class="woocommerce">
<div class="inner-content">
<?php
if ($loop->have_posts()) {
while ($loop->have_posts()) {
$loop->the_post();
wc_get_template_part('content', 'product-deals');
}
}
?>
</div>
</div>
<?php
wp_reset_query();
echo $after_widget;
}
示例2: clea_patrice_sold_out_shortcode
function clea_patrice_sold_out_shortcode($atts)
{
// allow sold out products in the query...
remove_action('pre_get_posts', 'clea_patrice_no_sold_out_in_shop');
global $woocommerce_loop;
extract(shortcode_atts(array('per_page' => '12', 'columns' => '3', 'orderby' => 'date', 'order' => 'desc'), $atts));
$woocommerce_loop['columns'] = $columns;
$args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_stock_status', 'value' => 'outofstock', 'compare' => '=')));
// Buffer our contents
ob_start();
do_action('woocommerce_before_shop_loop');
$loop = new WP_Query($args);
if ($loop->have_posts()) {
while ($loop->have_posts()) {
$loop->the_post();
wc_get_template_part('content', 'product');
}
} else {
echo __('No products found');
}
wp_reset_postdata();
do_action('woocommerce_after_shop_loop');
// Return buffered contents
return '<ul class="products">' . ob_get_clean() . '</ul>';
}
示例3: ro_woocommerce_content
function ro_woocommerce_content()
{
if (is_singular('product')) {
wc_get_template_part('single', 'product');
} else {
wc_get_template_part('archive', 'product');
}
}
示例4: spyropress_wc_shop_header
/** Add Shop Header */
function spyropress_wc_shop_header()
{
if (is_single()) {
return;
}
wc_get_template_part('global/shop', 'header');
}
示例5: content
protected function content($atts, $content = null)
{
$atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('lastest_deals_sidebar', $atts) : $atts;
$atts = shortcode_atts(array('title' => '', 'taxonomy' => '', 'number' => 12, 'autoplay' => "false", 'navigation' => "false", 'slidespeed' => 250, 'loop' => "false", 'items' => 1, 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
extract($atts);
$elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'latest-deals ', $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_lastest_deals_sidebar_class_container', $elementClass);
// Get products on sale
$product_ids_on_sale = wc_get_product_ids_on_sale();
$meta_query = WC()->query->get_meta_query();
$args = array('posts_per_page' => $number, 'post_type' => 'product', 'orderby' => 'meta_value_num', 'meta_key' => '_sale_price_dates_to', 'order' => 'DESC', 'no_found_rows' => 1, 'post_status' => 'publish', 'meta_query' => $meta_query, 'post__in' => array_merge(array(0), $product_ids_on_sale));
if ($taxonomy) {
$args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => explode(",", $taxonomy)));
}
$q = apply_filters('woocommerce_shortcode_products_query', $args, $atts);
$query = new WP_Query($q);
global $woocommerce_loop;
ob_start();
if ($query->have_posts()) {
$data_carousel = array("autoplay" => $autoplay, "navigation" => $navigation, "slidespeed" => $slidespeed, "autoheight" => "false", "loop" => $loop, "dots" => "false", 'nav' => "true", "autoplayTimeout" => 1000, "autoplayHoverPause" => "true", 'items' => 1);
add_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
add_filter('woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2);
?>
<div class="<?php
echo esc_attr($elementClass);
?>
">
<h2 class="latest-deal-title"><?php
echo esc_html($title);
?>
</h2>
<div class="latest-deal-content">
<ul class="product-list owl-carousel" <?php
echo _data_carousel($data_carousel);
?>
>
<?php
add_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
while ($query->have_posts()) {
$query->the_post();
wc_get_template_part('content', 'product-sidebar');
}
// end of the loop.
remove_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
?>
</ul>
</div>
</div>
<?php
remove_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
remove_filter('woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2);
}
wp_reset_postdata();
wp_reset_query();
$result = ob_get_contents();
ob_clean();
return $result;
}
示例6: content
protected function content($atts, $content = null)
{
$atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('list_product', $atts) : $atts;
$atts = shortcode_atts(array('title' => '', 'cat' => 0, 'number' => 4, 'types' => 'sale', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
extract($atts);
global $woocommerce_loop;
$elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'popular-tabs ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '));
$elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
ob_start();
$meta_query = WC()->query->get_meta_query();
$query = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $number, 'meta_query' => $meta_query);
global $woocommerce_loop;
$woocommerce_loop['columns'] = $number;
if ($cat > 0) {
$query['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $cat));
}
if ($types == 'arrival') {
$query['orderby'] = 'date';
$query['order'] = 'DESC';
}
if ($types == 'sale') {
$product_ids_on_sale = wc_get_product_ids_on_sale();
$query['meta_key'] = 'total_sales';
$query['orderby'] = 'meta_value_num';
$query['post__in'] = array_merge(array(0), $product_ids_on_sale);
}
if ($types == 'review') {
add_filter('posts_clauses', array($this, 'order_by_rating_post_clauses'));
}
$products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $query, $atts));
if ($types == 'review') {
remove_filter('posts_clauses', array($this, 'order_by_rating_post_clauses'));
}
if ($products->have_posts()) {
?>
<div class="mega-group">
<h4 class="mega-group-header"><span><?php
echo esc_html($title);
?>
</span></h4>
<div class="mega-products">
<?php
while ($products->have_posts()) {
$products->the_post();
?>
<?php
wc_get_template_part('content', 'product-verticalmenu');
?>
<?php
}
// end of the loop.
?>
</div>
</div>
<?php
}
return ob_get_clean();
}
示例7: content
protected function content($atts, $content = null)
{
$atts = shortcode_atts(array('product_type' => 'classic', 'product_effect' => '', 'desktop' => 4, 'per_page' => 10, 'orderby' => 'date', 'meta_key' => '', 'order' => 'DESC', 'source' => 'all', 'categories' => '', 'products' => '', 'operator' => 'IN', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
extract($atts);
$elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'cruxstore-products', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '), 'product_stype' => 'cruxstore-products-' . $product_type, 'woocommerce' => 'woocommerce columns-' . $desktop);
$meta_query = WC()->query->get_meta_query();
if ($source == 'best-sellers') {
$meta_key = 'total_sales';
$orderby = 'meta_value_num';
}
$args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'meta_query' => $meta_query, 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key);
if ($source == 'onsale') {
$product_ids_on_sale = wc_get_product_ids_on_sale();
$args['post__in'] = array_merge(array(0), $product_ids_on_sale);
} elseif ($source == 'featured') {
$args['meta_query'][] = array('key' => '_featured', 'value' => 'yes');
} elseif ($source == 'top-rated') {
add_filter('posts_clauses', array(__CLASS__, 'order_by_rating_post_clauses'));
} elseif ($source == 'categories') {
if (!empty($categories)) {
$args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array_map('sanitize_title', explode(',', $categories)), 'field' => 'slug', 'operator' => $operator));
}
} elseif ($source == 'products') {
if (!empty($atts['products'])) {
$args['post__in'] = array_map('trim', explode(',', $atts['products']));
}
}
$output = '';
ob_start();
global $woocommerce_loop;
$products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
if ($product_type != 'classic') {
$product_effect = '';
}
$woocommerce_loop['columns'] = $desktop;
$woocommerce_loop['type'] = $product_type;
$woocommerce_loop['effect'] = $product_effect;
if ($products->have_posts()) {
woocommerce_product_loop_start();
if ($product_type == 'masonry') {
echo '<div class="clearfix product col-sm-3 grid-sizer"></div>';
}
while ($products->have_posts()) {
$products->the_post();
wc_get_template_part('content', 'product');
}
// end of the loop.
woocommerce_product_loop_end();
}
wp_reset_postdata();
if ($source == 'top-rated') {
remove_filter('posts_clauses', array(__CLASS__, 'order_by_rating_post_clauses'));
}
$output .= ob_get_clean();
$elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
return '<div class="' . esc_attr($elementClass) . '">' . $output . '</div>';
}
示例8: widget
public function widget($args, $instance)
{
echo apply_filters('kt_wg_before_widget', $args['before_widget']);
$title = isset($instance['title']) && $instance['title'] ? esc_html($instance['title']) : '';
$orderby = isset($instance['orderby']) && $instance['orderby'] ? esc_attr($instance['orderby']) : 'date';
$order = isset($instance['order']) && $instance['order'] ? esc_attr($instance['order']) : 'desc';
$posts_per_page = isset($instance['posts_per_page']) && $instance['posts_per_page'] ? intval($instance['posts_per_page']) : '3';
$meta_query = WC()->query->get_meta_query();
$params = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $posts_per_page, 'meta_query' => $meta_query, 'suppress_filter' => true, 'orderby' => $orderby, 'order' => $order);
if ($title) {
echo apply_filters('kt_wg_before_title', $args['before_title']);
echo esc_html($title);
echo apply_filters('kt_wg_after_title', $args['after_title']);
}
$product = new WP_Query($params);
?>
<!-- SPECIAL -->
<div class="block left-module">
<div class="block_content">
<ul class="products-block">
<?php
if ($product->have_posts()) {
?>
<?php
while ($product->have_posts()) {
$product->the_post();
?>
<?php
wc_get_template_part('content', 'special-product-sidebar');
?>
<?php
}
?>
<?php
}
wp_reset_query();
wp_reset_postdata();
$shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
?>
</ul>
<div class="products-block">
<div class="products-block-bottom">
<a class="link-all" href="<?php
echo esc_url($shop_page_url);
?>
"><?php
esc_html_e('All Products', 'kutetheme');
?>
</a>
</div>
</div>
</div>
</div>
<!-- ./SPECIAL -->
<?php
echo apply_filters('kt_wg_after_widget', $args['after_widget']);
}
示例9: content
protected function content($atts, $content = null)
{
$atts = shortcode_atts(array('per_page' => 10, 'orderby' => 'date', 'meta_key' => '', 'order' => 'DESC', 'source' => '', 'categories' => '', 'products' => '', 'operator' => 'IN', 'layout' => 'normal', 'autoheight' => true, 'autoplay' => false, 'mousedrag' => true, 'autoplayspeed' => 5000, 'slidespeed' => 200, 'carousel_skin' => '', 'desktop' => 4, 'desktopsmall' => 3, 'tablet' => 2, 'mobile' => 1, 'gutters' => false, 'navigation' => true, 'navigation_always_on' => false, 'navigation_position' => 'center-outside', 'navigation_style' => 'normal', 'pagination' => false, 'pagination_position' => 'center-bottom', 'pagination_style' => 'dot-stroke', 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts);
extract($atts);
$elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'products-carousel ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'woocommerce' => 'woocommerce columns-' . $desktop, 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '), 'layout' => 'layout-' . $layout);
$meta_query = WC()->query->get_meta_query();
if ($source == 'best-sellers') {
$meta_key = 'total_sales';
$orderby = 'meta_value_num';
}
$args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'meta_query' => $meta_query, 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key);
if ($source == 'onsale') {
$product_ids_on_sale = wc_get_product_ids_on_sale();
$args['post__in'] = array_merge(array(0), $product_ids_on_sale);
} elseif ($source == 'featured') {
$args['meta_query'][] = array('key' => '_featured', 'value' => 'yes');
} elseif ($source == 'top-rated') {
add_filter('posts_clauses', array(__CLASS__, 'order_by_rating_post_clauses'));
} elseif ($source == 'categories') {
if (!empty($categories)) {
$args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array_map('sanitize_title', explode(',', $categories)), 'field' => 'slug', 'operator' => $operator));
}
} elseif ($source == 'products') {
if (!empty($atts['products'])) {
$args['post__in'] = array_map('trim', explode(',', $atts['products']));
}
}
$output = $carousel_html = '';
ob_start();
$products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
if ($products->have_posts()) {
global $woocommerce_loop;
$woocommerce_loop['columns'] = $desktop;
$carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts), '', 'wc-carousel-wrapper');
if ($layout == 'transparent') {
$woocommerce_loop['type'] = 'transparent';
} else {
$woocommerce_loop['type'] = 'normal';
}
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();
}
$carousel_html .= ob_get_clean();
wp_reset_postdata();
if ($carousel_html) {
$elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
$output = '<div class="' . esc_attr($elementClass) . '">' . str_replace('%carousel_html%', $carousel_html, $carousel_ouput) . '</div>';
}
return $output;
}
示例10: element
/**
* This method is used to display the output of the element.
* @return void
*/
function element()
{
// Prevent the elemnt from being accessible on other pages
if (!is_singular('product')) {
echo '<div class="zn-pb-notification">This element only works on single product pages created with WooCommerce. Please delete it.</div>';
return false;
}
echo '<div class="zn_post_content_elemenent ' . $this->data['uid'] . ' ' . $this->opt('css_class', '') . '">';
wc_get_template_part('content', 'single-product');
echo '</div>';
}
示例11: widget
public function widget($args, $instance)
{
echo apply_filters('kt_wg_before_widget', $args['before_widget']);
$title = isset($instance['title']) && $instance['title'] ? esc_html($instance['title']) : '';
$number = isset($instance['number']) && intval($instance['number']) ? intval($instance['number']) : 3;
$orderby = isset($instance['orderby']) && $instance['orderby'] ? esc_attr($instance['orderby']) : 'date';
$order = isset($instance['order']) && $instance['order'] ? esc_attr($instance['order']) : 'desc';
$meta_query = WC()->query->get_meta_query();
$product_ids_on_sale = wc_get_product_ids_on_sale();
$params = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $number, 'meta_query' => $meta_query, 'suppress_filter' => true, 'orderby' => $orderby, 'order' => $order, 'post__in' => array_merge(array(0), $product_ids_on_sale));
$product = new WP_Query($params);
if ($product->have_posts()) {
?>
<!-- block best sellers -->
<div class="block left-module">
<?php
if ($title) {
echo apply_filters('kt_wg_before_title', $args['before_title']);
echo esc_html($title);
echo apply_filters('kt_wg_after_title', $args['after_title']);
}
add_filter('woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2);
add_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
?>
<div class="block_content product-onsale">
<ul class="product-list owl-carousel" data-loop="false" data-nav = "false" data-margin = "0" data-autoplayTimeout="1000" data-autoplayHoverPause = "true" data-items="1" data-autoplay="false">
<?php
while ($product->have_posts()) {
$product->the_post();
?>
<li>
<?php
wc_get_template_part('content', 'on-sale-sidebar');
?>
</li>
<?php
}
?>
</ul>
</div>
<?php
remove_filter("woocommerce_get_price_html_from_to", "kt_get_price_html_from_to", 10, 4);
remove_filter('woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2);
?>
</div>
<!-- ./block best sellers -->
<?php
}
echo apply_filters('kt_wg_after_widget', $args['after_widget']);
}
示例12: filter_wc_template_rendering
/**
* Filter that replaces current woocommerce template with template defined in settings.
*
* @see beforeWCTemplateRender
* @param string $file full path to currently rendered template
* @return mixed
*/
public static function filter_wc_template_rendering($file)
{
if ($file && self::isTourProduct()) {
$anotherTemplate = '';
$map = self::$wcTemplatesMap;
$baseName = basename($file, '.php');
if (isset($map[$baseName])) {
wc_get_template_part($map[$baseName]);
// get_template_part($map[$baseName]);
return false;
}
}
return $file;
}
示例13: nm_ajax_load_product
function nm_ajax_load_product()
{
global $woocommerce, $product, $post;
//$post = $product = get_post( $_POST['product_id'] );
$product = get_product($_POST['product_id']);
$post = $product->post;
$output = '';
setup_postdata($post);
ob_start();
wc_get_template_part('quickview/content', 'quickview');
$output = ob_get_clean();
wp_reset_postdata();
echo $output;
exit;
}
示例14: pgl_woocommerce_switch_layout_ajax
function pgl_woocommerce_switch_layout_ajax()
{
$args = json_decode(base64_decode($_POST['query']));
$type = $_POST['type'];
$query = new WP_Query($args);
query_posts($args);
while ($query->have_posts()) {
$query->the_post();
if ($type == 'list') {
wc_get_template_part('content', 'product-list');
} else {
wc_get_template_part('content', 'product');
}
}
die;
}
示例15: new_products_lightspeed
function new_products_lightspeed($atts)
{
/**
* Featured Products shortcode
*
* @param array $atts
* @return string
*/
global $woocommerce_loop, $products, $product;
// include our handy API wrapper that makes it easy to call the API, it also depends on MOScURL to make the cURL call
require_once "MOSAPICall.class.php";
extract(shortcode_atts(array('per_page' => '12', 'columns' => '4', 'orderby' => 'date', 'order' => 'desc'), $atts));
$woocommerce_loop['columns'] = $columns;
ob_start();
$mosapi = new MOSAPICall("992e498dfa5ab5245f5bd5afee4ee1ce6ac6e0a1ee7d11e36480694a9b5282e7", "83442");
$emitter = 'https://api.merchantos.com/API/Account/83442/ItemMatrix';
$xml_query_string = 'limit=100&orderby=timeStamp&orderby_desc=1&load_relations=["ItemECommerce","Tags","Images"]';
$products = $mosapi->makeAPICall("Account.ItemMatrix", "Read", null, null, $emitter, $xml_query_string);
$wp_session = WP_Session::get_instance();
$products = xml2array($products);
$wp_session['products'] = $products;
//var_dump($wp_session['products']);
$i = 0;
//if ( $products->children() ) :
?>
<?php
woocommerce_product_loop_start();
?>
<?php
foreach ($products as $prod) {
foreach ($prod as $product) {
wc_get_template_part('content', 'lightspeedproduct');
}
}
// end of the loop.
?>
<?php
woocommerce_product_loop_end();
?>
<?php
//endif;
return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}