Overview
  • Namespace
  • Class

Namespaces

  • None
  • WC_POS
    • Admin
      • Settings
        • Receipt
    • API
    • Gateways
    • Integrations
    • Products

Classes

  • WC_POS\Activator
  • WC_POS\Admin
  • WC_POS\Admin\Gateways
  • WC_POS\Admin\Menu
  • WC_POS\Admin\Notices
  • WC_POS\Admin\Orders
  • WC_POS\Admin\Page
  • WC_POS\Admin\Permalink
  • WC_POS\Admin\Plugins
  • WC_POS\Admin\Products
  • WC_POS\Admin\Settings
  • WC_POS\Admin\Settings\Access
  • WC_POS\Admin\Settings\Checkout
  • WC_POS\Admin\Settings\Customers
  • WC_POS\Admin\Settings\Gateways
  • WC_POS\Admin\Settings\General
  • WC_POS\Admin\Settings\HotKeys
  • WC_POS\Admin\Settings\Page
  • WC_POS\Admin\Settings\Receipt\Options
  • WC_POS\Admin\Settings\Receipt\Template
  • WC_POS\Admin\Settings\Receipts
  • WC_POS\Admin\Settings\Status
  • WC_POS\Admin\Settings\Tools
  • WC_POS\Admin\Status
  • WC_POS\Ajax
  • WC_POS\API
  • WC_POS\API\Coupons
  • WC_POS\API\Customers
  • WC_POS\API\Gateways
  • WC_POS\API\i18n
  • WC_POS\API\Orders
  • WC_POS\API\Params
  • WC_POS\API\Payload
  • WC_POS\API\Products
  • WC_POS\API\Settings
  • WC_POS\API\Support
  • WC_POS\API\Templates
  • WC_POS\Customers
  • WC_POS\Deactivator
  • WC_POS\Gateways
  • WC_POS\Gateways\Card
  • WC_POS\Gateways\Cash
  • WC_POS\i18n
  • WC_POS\Integrations\Bookings
  • WC_POS\Products
  • WC_POS\Products\Visibility
  • WC_POS\Setup
  • WC_POS\Status
  • WC_POS\Tax
  • WC_POS\Template

Functions

  • is_pos
  • is_pos_admin
  • wc_pos_get_option
  • wc_pos_json_encode
  • wc_pos_locate_template
  • wc_pos_trim_html_string
  • wc_pos_update_option
  • wc_pos_url
 1 <?php
 2 
 3 /**
 4 * Loads the POS Payment Gateways
 5 *
 6 * @class    WC_POS_Gateways
 7 * @package  WooCommerce POS
 8 * @author   Paul Kilmurray <paul@kilbot.com.au>
 9 * @link     http://www.woopos.com.au
10 */
11 
12 namespace WC_POS;
13 
14 class Gateways {
15 
16   protected static $instance;
17 
18   /**
19    * Constructor
20    */
21   public function __construct() {
22     add_action( 'woocommerce_payment_gateways', array( $this, 'payment_gateways' ) );
23     add_action( 'woocommerce_pos_load_gateways', array( $this, 'load_gateways' ) );
24 
25     static::$instance = $this;
26   }
27 
28   /**
29    * Returns the Singleton instance of this class.
30    * - late static binding requires PHP 5.3+
31    * @return Singleton
32    */
33   public static function get_instance() {
34     $class = get_called_class();
35     if (null === static::$instance) {
36       static::$instance = new $class();
37     }
38     return static::$instance;
39   }
40 
41   /**
42    * Add POS gateways
43    * @param $gateways
44    * @return array
45    */
46   public function payment_gateways( array $gateways ) {
47     global $plugin_page;
48 
49     // don't show POS gateways on WC settings page or online checkout
50     if( is_admin() && $plugin_page == 'wc-settings' || !is_admin() && !is_pos() ){
51       return $gateways;
52     }
53 
54     return array_merge($gateways, array(
55       'WC_POS\Gateways\Cash',
56       'WC_POS\Gateways\Card'
57     ));
58   }
59 
60   /**
61    * Enable POS gateways
62    * @param $gateways
63    * @return bool
64    */
65   public function load_gateways( $gateways ) {
66     foreach( $gateways as $gateway ){
67       $gateway->pos = in_array( $gateway->id, array( 'pos_cash', 'pos_card', 'paypal' ) );
68     }
69     return $gateways;
70   }
71 
72 }
API documentation generated by ApiGen