doushun1904 2018-03-29 09:13
浏览 67
已采纳

哪个钩子可以根据用户角色过滤Woocommerce产品

I'm trying to filter the products based on the the type of customer that logs in. Using an attribute in the customer record which filter method would I use to automatically filter certain products from a custom so they cannot see them?

I've come across 'woocommerce_product_filters' in the docs but I'm not sure if this is the correct hook to use.

Any pointers would be a great help

  • 写回答

1条回答 默认 最新

  • dtjw6660 2018-03-29 09:44
    关注

    To alter the product query in woocommerce archive pages and shop, you should better use on of this hooks:

    • woocommerce_product_query (action hook)
    • woocommerce_product_query_tax_query (filter hook)
    • woocommerce_product_query_meta_query (filter hook)

    There is many examples on StackOverFlow and you will be able to filter easily from user roles using conditional function current_user_can( 'the_user_role' )

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料