【问题标题】:WooCommerce - Hide tax for user roleWooCommerce - 隐藏用户角色的税金
【发布时间】:2017-08-12 06:40:19
【问题描述】:

在我们的网店中,我们需要显示公司的不含税价格和个人的含税价格。两者都要纳税,所以我们只需要根据用户角色(客户与公司)更改视图设置(woocommerce_tax_display_shop 和 woocommerce_tax_display_cart)。

我们无法弄清楚。谁能帮帮我们?

【问题讨论】:

  • 你检查thisthis还有this等等问题,也许这可以帮助你。

标签: wordpress woocommerce


【解决方案1】:

pre_option_ + your option 将为您提供过滤器的名称,您可以使用它“在显示特定视图之前临时更改 WordPress 选项”

https://codex.wordpress.org/Plugin_API/Filter_Reference/pre_option_%28option_name%29

您需要为您的购物车选项使用相同的选项。

add_filter('pre_option_woocommerce_tax_display_shop', 'alter_tax_display');


function alter_tax_display( $tax_display ) {
    if (current_user_can("company")){
    return "excl";
  } else {
    return "incl";
}

【讨论】:

  • 嗨。这没有用。首先,没有名为 get_current_user_role() 的函数。它也不适用于此: in_array( 'company', (array) $user->roles)
  • 我编辑了答案,如果这是您的角色,您可以尝试使用 current_user_can("company")。
猜你喜欢
  • 2018-03-22
  • 2015-06-21
  • 2015-08-26
  • 2019-11-04
  • 2017-02-11
  • 2013-07-25
  • 1970-01-01
  • 2020-11-17
  • 1970-01-01
相关资源
最近更新 更多