【问题标题】:WooCommerce: Display ONLY discounted product in listWooCommerce:仅在列表中显示打折产品
【发布时间】:2015-10-07 16:28:46
【问题描述】:

从这个问题 WooCommerce: Display ONLY on-sale products in Shop 我试图展示那些打折的产品。但每次它显示的所有产品都是 on_sale 。 我还尝试了_sale_price 元键。但不明白我该如何解决我的问题。 我的代码中的项目输出

我的$args变量

$args = array(
'post_type'      => 'product',
'order'          => 'ASC',
'meta_query'     => array(
    array(
        'key'           => '_sale_price',
        'value'         => 0,
        'compare'       => '>',
        'type'          => 'numeric'
    )
)
);

我也试过下面的代码。但是结果一样

$args = array(
'post_type'      => 'product',
'posts_per_page' => 8,
'meta_query'     => array(
    'relation' => 'OR',
    array( // Simple products type
        'key'           => '_sale_price',
        'value'         => 0,
        'compare'       => '>',
        'type'          => 'numeric'
    ),
    array( // Variable products type
        'key'           => '_min_variation_sale_price',
        'value'         => 0,
        'compare'       => '>',
        'type'          => 'numeric'
    )
)
);

【问题讨论】:

    标签: wordpress woocommerce woothemes


    【解决方案1】:

    我如何解决我的问题。当我从管理面板发布产品时,我错了。我的代码是正确的。当我发布产品时,我将价格设置为销售价格而不是正常价格。现在我删除了那些没有打折的产品销售价格。并将这个价格放在正常价格上。现在我的问题解决了。这是我的输出。

    我在管理面板中的工作

    【讨论】:

      猜你喜欢
      • 2014-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-06
      • 2014-06-18
      • 2018-10-12
      • 2015-12-30
      • 2021-02-04
      相关资源
      最近更新 更多