WC_POS_Admin_Settings_Checkout

WP Checkout Settings Class.

Defined (1)

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

/includes/admin/settings/class-wc-pos-checkout.php  
  1. class WC_POS_Admin_Settings_Checkout extends WC_POS_Admin_Settings_Abstract { 
  2.  
  3. protected static $instance; 
  4.  
  5. /** 
  6. * Each settings tab requires an id and label 
  7. */ 
  8. public function __construct() { 
  9. $this->id = 'checkout'; 
  10. /** translators: woocommerce */ 
  11. $this->label = __( 'Checkout', 'woocommerce' ); 
  12.  
  13. $this->defaults = array( 
  14. 'order_status' => 'wc-completed',  
  15. 'default_gateway' => 'pos_cash',  
  16. 'enabled' => array( 
  17. 'pos_cash' => true,  
  18. 'pos_card' => true,  
  19. 'paypal' => true 
  20. ); 
  21.  
  22. public function load_gateways() { 
  23. $gateways = WC_Payment_Gateways::instance()->payment_gateways; 
  24. $order = $this->get('gateway_order'); 
  25.  
  26. // some poorly written plugins will init WC_Payment_Gateways before WP init 
  27. // check to see if POS Cash Gateway is present, if not: re-init WC_Payment_Gateways 
  28. if( ! in_array( 'WC_POS_Gateways_Cash', array_map( 'get_class', $gateways ) ) ) { 
  29. WC_Payment_Gateways::instance()->init(); 
  30. $gateways = WC_Payment_Gateways::instance()->payment_gateways; 
  31.  
  32. // some poorly written plugins will init WC_Payment_Gateways before WP init 
  33. // check to see if POS Cash Gateway is present, if not: re-init WC_Payment_Gateways 
  34. if( ! in_array( 'WC_POS_Gateways_Cash', array_map( 'get_class', $gateways ) ) ) { 
  35. WC_Payment_Gateways::instance()->init(); 
  36. $gateways = WC_Payment_Gateways::instance()->payment_gateways; 
  37.  
  38. // reorder 
  39. $i = count($gateways); 
  40. foreach( $gateways as $gateway ) { 
  41. if( isset( $order[$gateway->id] ) ) { 
  42. $ordered_gateways[ $order[$gateway->id] ] = $gateway; 
  43. } else { 
  44. $ordered_gateways[ ++$i ] = $gateway; 
  45. $settings = new WC_POS_Admin_Settings_Gateways($gateway->id); 
  46. $settings->merge_settings($gateway); 
  47. apply_filters( 'woocommerce_pos_load_gateway', $gateway ); 
  48.  
  49. ksort( $ordered_gateways, SORT_NUMERIC ); 
  50. return $ordered_gateways; 
  51.  
  52. public function load_enabled_gateways() { 
  53. $gateways = $this->load_gateways(); 
  54. $enabled = $this->get_enabled_gateway_ids(); 
  55. $default = $this->get('default_gateway'); 
  56. $_gateways = array(); 
  57.  
  58. if($gateways): foreach($gateways as $gateway): 
  59. $id = $gateway->id; 
  60. if(in_array($id, $enabled) && isset($gateway->pos) && $gateway->pos) { 
  61. $gateway->default = $id == $default; 
  62. // $gateway->enabled = 'yes'; // gets stomped later by init_settings() 
  63. $_gateways[$id] = $gateway; 
  64. endforeach; endif; 
  65.  
  66. return $_gateways; 
  67.  
  68. public function get_enabled_gateway_ids() { 
  69. return array_keys( (array) $this->get('enabled'), true); 
  70.