WC_Payment_Discounts

WooCommerce Discounts Per Payment Method plugin.

Defined (1)

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

/woocommerce-payment-discounts.php  
  1. class WC_Payment_Discounts { 
  2.  
  3. /** 
  4. * Plugin version. 
  5. * @var string 
  6. */ 
  7. const VERSION = '3.0.0'; 
  8.  
  9. /** 
  10. * Instance of this class. 
  11. * @var object 
  12. */ 
  13. protected static $instance = null; 
  14.  
  15. /** 
  16. * Initialize the plugin. 
  17. */ 
  18. private function __construct() { 
  19. // Load plugin text domain. 
  20. add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); 
  21.  
  22. if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.0', '>=' ) ) { 
  23. $this->includes(); 
  24.  
  25. if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { 
  26. $this->admin_includes(); 
  27. } else { 
  28. add_action( 'admin_notices', array( $this, 'woocommerce_is_missing_notice' ) ); 
  29.  
  30. /** 
  31. * Return an instance of this class. 
  32. * @return object A single instance of this class. 
  33. */ 
  34. public static function get_instance() { 
  35. // If the single instance hasn't been set, set it now. 
  36. if ( null == self::$instance ) { 
  37. self::$instance = new self; 
  38.  
  39. return self::$instance; 
  40.  
  41. /** 
  42. * Includes. 
  43. */ 
  44. protected function includes() { 
  45. include_once dirname( __FILE__ ) . '/includes/class-wc-payment-discounts-coupons.php'; 
  46. include_once dirname( __FILE__ ) . '/includes/class-wc-payment-discounts-apply-discount.php'; 
  47.  
  48. /** 
  49. * Admin includes. 
  50. */ 
  51. protected function admin_includes() { 
  52. include_once dirname( __FILE__ ) . '/includes/admin/class-wc-payment-discounts-admin.php'; 
  53.  
  54. /** 
  55. * Fired for each blog when the plugin is activated. 
  56. */ 
  57. public static function activate() { 
  58. add_option( 'woocommerce_payment_discounts', array() ); 
  59. add_option( 'woocommerce_payment_discounts_version', self::VERSION ); 
  60.  
  61. /** 
  62. * Load the plugin text domain for translation. 
  63. */ 
  64. public function load_plugin_textdomain() { 
  65. load_plugin_textdomain( 'woocommerce-payment-discounts', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 
  66.  
  67. /** 
  68. * WooCommerce missing notice. 
  69. * @return string Admin notice. 
  70. */ 
  71. public function woocommerce_is_missing_notice() { 
  72. echo '<div class="error"><p><strong>' . __( 'WooCommerce Discounts Per Payment Method', 'woocommerce-payment-discounts' ) . '</strong> ' . sprintf( __( 'works only with %s 3.0 or later, please install or upgrade your installation!', 'woocommerce-payment-discounts' ), '<a href="http://wordpress.org/plugins/woocommerce/">' . __( 'WooCommerce', 'woocommerce-payment-discounts' ) . '</a>' ) . '</p></div>';