【问题标题】:Woocommerce Sorting function is not working with WOOF - WooCommerce Products FilterWoocommerce 排序功能不适用于 WOOF - WooCommerce 产品过滤器
【发布时间】:2018-08-29 05:07:08
【问题描述】:

我正在尝试在我的 wordpress 网站的商店页面上添加按评级、价格和受欢迎程度排序的选项。

另外,想按属性添加过滤器。

我使用 WOOF - WooCommerce 产品过滤器 来添加过滤器选项。我的排序选项不适用于此。

【问题讨论】:

  • 请先阅读此内容。 stackoverflow.com/help/how-to-ask
  • 在 WOOF - WooCommerce 产品过滤器设置中,您可以启用扩展。有按等级排序,按价格排序,特色产品。你使用这些扩展吗?如果没有,请启用这些扩展并点击“保存”。
  • 感谢您的回复。我已经尝试过这些扩展,但它显示的过滤器是从 1 到 2、2 到 3、2 到 3、3 到 4 或 4 到 5 的评级。我想要排序下拉菜单下的所有选项,如下面的网站。 reebonz.com/sg/women/indemand/bags

标签: php wordpress woocommerce


【解决方案1】:

我正在使用相同的 sn-p,它工作正常。您可以使用 woocommerce 的自定义选项并使用任意数量的排序。

add_filter('woof_order_catalog', function($sort_args){

$sort_args['orderby'] = 'meta_value';
// Sort by meta_value because we're using alphabetic sorting
$sort_args['order'] = 'asc';
$sort_args['meta_key'] = 'meta-key';

return $sort_args;

});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多