本文整理汇总了PHP中woocommerce_related_products函数的典型用法代码示例。如果您正苦于以下问题:PHP woocommerce_related_products函数的具体用法?PHP woocommerce_related_products怎么用?PHP woocommerce_related_products使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了woocommerce_related_products函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: woocommerce_output_related_products
function woocommerce_output_related_products()
{
$output = null;
ob_start();
woocommerce_related_products(array('columns' => 4, 'posts_per_page' => 4));
$content = ob_get_clean();
if ($content) {
$output .= $content;
}
echo '<div class="clear"></div>' . $output;
}
示例2: woocommerce_output_related_products
function woocommerce_output_related_products()
{
// Build the args
$args = array('posts_per_page' => 4, 'columns' => 4);
// Update settings
woocommerce_related_products($args);
}
示例3: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
global $woocommerce;
// Use default title as fallback
$title = '' === $instance['title'] ? __('Related Products', 'woocommerce') : $instance['title'];
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
// Setup product query
$query_args = array('post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => $instance['number'], 'orderby' => 'rand');
if ($instance['show_variations']) {
$query_args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'));
$query_args['post_parent'] = 0;
}
$query = new WP_Query($query_args);
if ($query->have_posts()) {
echo $args['before_widget'];
if ('' !== $title) {
echo $args['before_title'], $title, $args['after_title'];
}
?>
<ul class="product_list_widget_related">
<!-- <?php
//while ($query->have_posts()) : $query->the_post(); global $product;
?>
<li>
<a href="<?php
//the_permalink()
?>
">
<?php
//if ( has_post_thumbnail() ) {
// the_post_thumbnail('shop_thumbnail');
//} else {
// echo '<img src="'. woocommerce_placeholder_img_src() .'" alt="Placeholder" width="'.$woocommerce->get_image_size( 'shop_thumbnail_image_width' ).'" height="'.$woocommerce->get_image_size( 'shop_thumbnail_image_height' ).'" />';
//}
?>
<?php
//the_title()
?>
</a>
<?php
//echo $product->get_price_html()
?>
</li>
<?php
//endwhile;
?>
--> <?php
echo woocommerce_related_products(3, 1);
?>
</ul>
<?php
echo $args['after_widget'];
}
}
示例4: woocommerce_after_single_product_summary
/**
* This function changes the number of related products displayed on a single product page.
*/
function woocommerce_after_single_product_summary()
{
woocommerce_related_products(array('posts_per_page' => 3, 'columns' => 3));
}
示例5: woocommerce_output_related_products
function woocommerce_output_related_products()
{
$related_posts = 4;
// 4 is default number
if (is_singular('product')) {
$page_layout = get_post_meta(get_the_ID(), '_et_pb_page_layout', true);
if ('et_full_width_page' !== $page_layout) {
$related_posts = 3;
// set to 3 if page has sidebar
}
}
$woocommerce_args = array('posts_per_page' => $related_posts, 'columns' => $related_posts);
woocommerce_related_products($woocommerce_args);
}
示例6: woocommerce_output_related_products
function woocommerce_output_related_products()
{
woocommerce_related_products(2, 2);
}
示例7: avia_woocommerce_output_related_products
function avia_woocommerce_output_related_products()
{
global $avia_config;
echo "<div class='product_column product_column_" . $avia_config['shop_single_column'] . "'>";
woocommerce_related_products($avia_config['shop_single_column_items'], $avia_config['shop_single_column']);
// 4 products, 4 columns
echo "</div>";
}
示例8: related_products
/**
* @param array $atts
* @return string
*/
public static function related_products($atts)
{
$atts = shortcode_atts(array('posts_per_page' => '2', 'columns' => '2', 'orderby' => 'rand', 'per_page' => ''), $atts);
if (!empty($atts['per_page'])) {
_deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.1', __('Use $args["posts_per_page"] instead. Deprecated argument will be removed in WC 2.2.', 'woocommerce'));
$atts['posts_per_page'] = $atts['per_page'];
unset($atts['per_page']);
}
ob_start();
woocommerce_related_products($atts);
return ob_get_clean();
}
示例9: woocommerce_output_related_products
function woocommerce_output_related_products()
{
woocommerce_related_products(8, 4);
// Display 3 products in rows of 3
}
示例10: woocommerce_output_related_products
/**
* Redefine woocommerce_output_related_products()
*/
function woocommerce_output_related_products()
{
woocommerce_related_products(array('columns' => 4, 'posts_per_page' => 4));
}
示例11: related_products
/**
* List related products.
* @param array $atts
* @return string
*/
public static function related_products($atts)
{
$atts = shortcode_atts(array('per_page' => '4', 'columns' => '4', 'orderby' => 'rand'), $atts);
ob_start();
// Rename arg
$atts['posts_per_page'] = absint($atts['per_page']);
woocommerce_related_products($atts);
return ob_get_clean();
}
示例12: woocommerce_output_related_products
function woocommerce_output_related_products()
{
woocommerce_related_products(4, 4);
// Показать 4 товара а 4 колонки
}
示例13: do_action
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
*/
do_action('woocommerce_single_product_summary');
?>
</div><!-- .summary -->
<?php
/**
* woocommerce_after_single_product_summary hook
*
* @hooked woocommerce_output_product_data_tabs - 10
* @hooked woocommerce_output_related_products - 20
*/
do_action('woocommerce_after_single_product_summary');
?>
<div class="clearfix"></div>
<?php
woocommerce_related_products();
?>
</div><!-- #product-<?php
the_ID();
?>
-->
<?php
do_action('woocommerce_after_single_product');
示例14: woocommerce_output_related_products
function woocommerce_output_related_products()
{
// Display related products in correct layout.
global $woo_options, $post;
$products_max = $woo_options['woocommerce_related_products_maximum'] + 2;
$products_cols = 4;
woocommerce_related_products($products_max, $products_cols);
}
示例15: child_after_summary
static function child_after_summary()
{
woocommerce_related_products(array('posts_per_page' => 4, 'columns' => 4));
}