Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress WooCommerce:如何禁用/启用特定货币的货到付款网关?_Wordpress_Woocommerce_Currency_Code Snippets - Fatal编程技术网

Wordpress WooCommerce:如何禁用/启用特定货币的货到付款网关?

Wordpress WooCommerce:如何禁用/启用特定货币的货到付款网关?,wordpress,woocommerce,currency,code-snippets,Wordpress,Woocommerce,Currency,Code Snippets,我发现这段代码是关于禁用基于国家/地区的付款方式的,有没有办法禁用基于“货币”的付款方式 /** *@snippet-woocmerce禁用特定国家/地区的支付网关 *@how-to-Watch教程@https://businessbloomer.com/?p=19055 *@sourcecodehttps://businessbloomer.com/?p=164 *@作者鲁道夫·梅洛格利 *@3.5.7 *@捐赠9美元https://businessbloomer.com/bloomer-ar

我发现这段代码是关于禁用基于国家/地区的付款方式的,有没有办法禁用基于“货币”的付款方式

/**
*@snippet-woocmerce禁用特定国家/地区的支付网关
*@how-to-Watch教程@https://businessbloomer.com/?p=19055
*@sourcecodehttps://businessbloomer.com/?p=164
*@作者鲁道夫·梅洛格利
*@3.5.7
*@捐赠9美元https://businessbloomer.com/bloomer-armada/
*/
添加过滤器(“woocommerce可用支付网关”、“bbloomer支付网关”禁用国家/地区);
功能bbloomer\u payment\u gateway\u disable\u country($available\u gateways){
如果(is_admin())返回$available_gateways;
如果(isset($available_gateways['authorize'])和&WC()->customer->get_billing_country()'US'){
未设置($available_gateways['authorize']);
}否则{
如果(isset($available_gateways['paypal'])和&WC()->customer->get_billing_country()='US'){
未设置($available_gateways['paypal']);
}
}
返回$available\u网关;
}

我只希望货到付款选项显示所选货币是否为PKR。我正在使用WooCommerce货币切换器插件切换货币。

请将以下代码粘贴到当前活动的主题functions.php文件中

function disable_cod_for_pkr_filter_gateways($gateway_list)
{
  //return if admin
  if ( is_admin() ) 
    return $available_gateways;

  //check currency
  $currency = get_woocommerce_currency(); 

  if ($currency == 'PKR')
  {
     unset($gateway_list['cod']);
  }

  return $gateway_list;
}
add_filter('woocommerce_available_payment_gateways', 'disable_cod_for_pkr_filter_gateways', 1);
我希望它能帮助你

function disable_cod_for_pkr_filter_gateways($gateway_list)
{
  //return if admin
  if ( is_admin() ) 
    return $available_gateways;

  //check currency
  $currency = get_woocommerce_currency(); 

  if ($currency == 'PKR')
  {
     unset($gateway_list['cod']);
  }

  return $gateway_list;
}
add_filter('woocommerce_available_payment_gateways', 'disable_cod_for_pkr_filter_gateways', 1);