本文整理汇总了PHP中wc_get_featured_product_ids函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_featured_product_ids函数的具体用法?PHP wc_get_featured_product_ids怎么用?PHP wc_get_featured_product_ids使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_get_featured_product_ids函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: switch
switch ($product_from) {
case 'product':
if (!empty($products)) {
$args['post__in'] = $products;
}
break;
case 'category':
if (!empty($category)) {
$args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $category, 'operator' => 'IN'));
}
break;
case 'onsale':
$args['post__in'] = wc_get_product_ids_on_sale();
break;
case 'featured':
$args['post__in'] = wc_get_featured_product_ids();
break;
default:
}
$products = get_posts($args);
if (empty($products)) {
return;
}
$product_id = 0;
foreach ($products as $product) {
$product_id = $product->ID;
}
$product = wc_get_product($product_id);
$product_type = $product->product_type;
if ($product_type == "simple") {
$yit_addtocart_url = add_query_arg('add-to-cart', $product->id, home_url());
开发者ID:JacerOmri,项目名称:yith-woocommerce-popup,代码行数:31,代码来源:woocommerce.php
示例2: woocommerce_get_featured_product_ids
/**
* @deprecated
*/
function woocommerce_get_featured_product_ids()
{
return wc_get_featured_product_ids();
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php
示例3: storefront_promoted_products
function storefront_promoted_products($per_page = '2', $columns = '2', $recent_fallback = true)
{
if (is_woocommerce_activated()) {
if (wc_get_featured_product_ids()) {
echo '<h2>' . esc_html__('Featured Products', 'storefront') . '</h2>';
echo storefront_do_shortcode('featured_products', array('per_page' => $per_page, 'columns' => $columns));
} elseif (wc_get_product_ids_on_sale()) {
echo '<h2>' . esc_html__('On Sale Now', 'storefront') . '</h2>';
echo storefront_do_shortcode('sale_products', array('per_page' => $per_page, 'columns' => $columns));
} elseif ($recent_fallback) {
echo '<h2>' . esc_html__('New In Store', 'storefront') . '</h2>';
echo storefront_do_shortcode('recent_products', array('per_page' => $per_page, 'columns' => $columns));
}
}
}
开发者ID:alexgomes09,项目名称:topshop,代码行数:15,代码来源:template-tags.php
示例4: add_featured_args_query
public function add_featured_args_query($args = array())
{
$woocommerce_db_version = get_option('woocommerce_db_version', null);
// Delete featured cached
delete_transient('wc_featured_products');
// Get featured products
$product_ids_featured = version_compare($woocommerce_db_version, '2.1', '<') ? woocommerce_get_featured_product_ids() : wc_get_featured_product_ids();
$meta_query = array();
if (version_compare($woocommerce_db_version, '2.1', '<')) {
global $woocommerce;
$meta_query[] = $woocommerce->query->visibility_meta_query();
$meta_query[] = $woocommerce->query->stock_status_meta_query();
} else {
$meta_query[] = WC()->query->visibility_meta_query();
$meta_query[] = WC()->query->stock_status_meta_query();
}
$args['meta_query'] = $meta_query;
$args['post__in'] = $product_ids_featured;
return $args;
}
开发者ID:TheTypoMaster,项目名称:wp_marketplace,代码行数:20,代码来源:class-legacy-api.php
示例5: pbo_featured_products
function pbo_featured_products($tag_class, $max_rows, $max_colums, $caption = '')
{
if (wc_get_featured_product_ids()) {
pbo_run_woocommerce_products_shortcode('featured_products', esc_html($caption === '' ? __('Featured products', 'pbo-tools') : $caption), $tag_class, $max_rows, $max_colums);
}
}
开发者ID:boguslawski-piotr,项目名称:pbo-tools,代码行数:6,代码来源:products.php
示例6: test_wc_get_featured_product_ids
/**
* Test wc_get_featured_product_ids()
*
* @since 2.4
*/
public function test_wc_get_featured_product_ids()
{
$this->assertEquals(array(), wc_get_featured_product_ids());
delete_transient('wc_featured_products');
// Create product
$product = \WC_Helper_Product::create_simple_product();
update_post_meta($product->id, '_featured', 'yes');
$this->assertEquals(array($product->id), wc_get_featured_product_ids());
// Delete Product
\WC_Helper_Product::delete_product($product->id);
}
开发者ID:nightbook,项目名称:woocommerce,代码行数:16,代码来源:functions.php
示例7: test_wc_get_featured_product_ids
/**
* Test wc_get_featured_product_ids().
*
* @since 2.4
*/
public function test_wc_get_featured_product_ids()
{
$this->assertEquals(array(), wc_get_featured_product_ids());
delete_transient('wc_featured_products');
// Create product
$product = WC_Helper_Product::create_simple_product();
$product->set_featured(true);
$product->save();
$this->assertEquals(array($product->get_id()), wc_get_featured_product_ids());
// Delete Product
WC_Helper_Product::delete_product($product->get_id());
}
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:17,代码来源:functions.php
注:本文中的wc_get_featured_product_ids函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论