WC_POS

The main POS Class.

Defined (1)

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

/includes/class-wc-pos.php  
  1. class WC_POS { 
  2.  
  3. /** 
  4. * Constructor 
  5. */ 
  6. public function __construct() { 
  7.  
  8. // auto load classes 
  9. if ( function_exists( 'spl_autoload_register' ) ) { 
  10. spl_autoload_register( array( $this, 'autoload' ) ); 
  11.  
  12. add_action( 'init', array( $this, 'init' ) ); 
  13. add_action( 'woocommerce_api_loaded', array( $this, 'load_woocommerce_api_patches') ); 
  14. add_action( 'rest_api_init', array( $this, 'load_woocommerce_apiv2_patches') ); 
  15.  
  16. // emails filter called very early :( 
  17. add_filter( 'woocommerce_defer_transactional_emails', array( $this, 'defer_transactional_emails' ) ); 
  18.  
  19. do_action( 'woocommerce_pos_loaded' ); 
  20.  
  21.  
  22. /** 
  23. * Autoload classes + pseudo namespacing 
  24. * turns WC_POS_i18n into includes/class-wc-pos-i18n.php and 
  25. * WC_POS_Admin_Settings into includes/admin/class-wc-pos-settings.php 
  26. * @param $class 
  27. */ 
  28. private function autoload( $class ) { 
  29. $cn = preg_replace( '/^wc_pos_/', '', strtolower( $class ), 1, $count ); 
  30. if( $count ) { 
  31. $path = explode('_', $cn); 
  32. if( $path[0] == 'pro' ) return; 
  33. $last = 'class-wc-pos-'. array_pop( $path ) .'.php'; 
  34. array_push( $path, $last ); 
  35. $file = WC_POS_PLUGIN_PATH . 'includes/' . implode( '/', $path ); 
  36. if( is_readable( $file ) ) 
  37. require_once $file; 
  38.  
  39. /** 
  40. * Load the required resources 
  41. */ 
  42. public function init() { 
  43.  
  44. // global helper functions 
  45. require_once WC_POS_PLUGIN_PATH . 'includes/wc-pos-functions.php'; 
  46.  
  47. // global classes 
  48. new WC_POS_i18n(); 
  49. new WC_POS_Gateways(); 
  50. new WC_POS_Products(); 
  51. new WC_POS_Template(); 
  52. new WC_POS_Customers(); 
  53.  
  54. // end global classes 
  55. if( !is_admin() ) 
  56. return; 
  57.  
  58. // ajax only 
  59. if( defined('DOING_AJAX') && DOING_AJAX ) { 
  60. new WC_POS_Settings(); 
  61. new WC_POS_AJAX(); 
  62.  
  63. // admin only 
  64. else { 
  65. new WC_POS_Admin(); 
  66.  
  67.  
  68. /** 
  69. */ 
  70. public function load_woocommerce_api_patches() { 
  71. new WC_POS_API(); 
  72.  
  73. /** 
  74. */ 
  75. public function load_woocommerce_apiv2_patches() { 
  76. new WC_POS_APIv2(); 
  77.  
  78.  
  79. /** 
  80. * Don't defer emails for POS orders 
  81. * @param $defer 
  82. * @return bool 
  83. */ 
  84. public function defer_transactional_emails( $defer ) { 
  85. if( is_pos() ) { 
  86. return false; 
  87. return $defer; 
  88.