wpppayment_gateway_disable_country

The Woocommerce Product Payments wpppayment gateway disable country function.

Description

wpppayment_gateway_disable_country( (type) $available_gateways ); 

Parameters (1)

0. $available_gateways (type)
The available gateways.

Usage

  1. if ( !function_exists( 'wpppayment_gateway_disable_country' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-product-payments/index.php'; 
  3.  
  4. // The available gateways. 
  5. $available_gateways = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wpppayment_gateway_disable_country($available_gateways); 
  9.  

Defined (1)

The function is defined in the following location(s).

/index.php  
  1. function wpppayment_gateway_disable_country($available_gateways) { 
  2. global $woocommerce; 
  3. $arrayKeys = array_keys($available_gateways); 
  4. if (count($woocommerce->cart)) { 
  5. $items = $woocommerce->cart->cart_contents; 
  6. $itemsPays = ''; 
  7. if (is_array($items)) { 
  8. foreach ($items as $item) { 
  9. $itemsPays = get_post_meta($item['product_id'], 'payments', true); 
  10. if (is_array($itemsPays) && count($itemsPays)) { 
  11. foreach ($arrayKeys as $key) { 
  12. if (array_key_exists($key, $available_gateways) && !in_array($available_gateways[$key]->id, $itemsPays)) { 
  13. unset($available_gateways[$key]); 
  14. return $available_gateways;