WC_POS_Gateways

Loads the POS Payment Gateways.

Defined (1)

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

/includes/class-wc-pos-gateways.php  
  1. class WC_POS_Gateways { 
  2.  
  3. /** 
  4. * Constructor 
  5. */ 
  6. public function __construct() { 
  7. $this->init(); 
  8. add_action( 'woocommerce_payment_gateways', array( $this, 'payment_gateways' ) ); 
  9. add_action( 'woocommerce_pos_load_gateway', array( $this, 'load_gateway' ) ); 
  10.  
  11. /** 
  12. * Sub classes 
  13. */ 
  14. private function init() { 
  15. // admin only 
  16. if (is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX)) { 
  17. new WC_POS_Admin_Gateways(); 
  18.  
  19. /** 
  20. * Add POS gateways 
  21. * @param $gateways 
  22. * @return array 
  23. */ 
  24. public function payment_gateways( array $gateways ) { 
  25. global $plugin_page; 
  26.  
  27. // don't show POS gateways on WC settings page or online checkout 
  28. if( is_admin() && $plugin_page == 'wc-settings' || !is_admin() && !is_pos() ) { 
  29. return $gateways; 
  30.  
  31. return array_merge($gateways, array( 
  32. 'WC_POS_Gateways_Cash',  
  33. 'WC_POS_Gateways_Card' 
  34. )); 
  35.  
  36. /** 
  37. * Enable POS gateways 
  38. * @param $gateway 
  39. * @return bool 
  40. */ 
  41. public function load_gateway( WC_Payment_Gateway $gateway ) { 
  42. $gateway->pos = in_array( $gateway->id, array( 'pos_cash', 'pos_card', 'paypal' ) ); 
  43. return $gateway; 
  44.