-
Notifications
You must be signed in to change notification settings - Fork 1
/
partial-cod-payment-gateway-restrictions-fees.php
103 lines (70 loc) · 2.95 KB
/
partial-cod-payment-gateway-restrictions-fees.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/*
* Plugin Name: WooCommerce Partial COD - Payment Gateway Restrictions & Fees
* Plugin URI: https://codecanyon.net/item/woocommerce-partial-cod-payment-gateway-restrictions-fees/41741012?ref=zendcrew
* Description: A powerful, flexible and easy-to-use WooCommerce extention that can be used to manage payment availability and other gateway options based on product rules and conditions.
* Version: 1.3.2
* Author: zendcrew
* Author URI: https://codecanyon.net/user/zendcrew?ref=zendcrew
* Text Domain: woopcd-partialcod
* Domain Path: /languages/
* Requires at least: 5.8
* Requires PHP: 5.6
* WC requires at least: 5.6
*
* Tested up to: 6.6
* WC tested up to: 9.2
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( is_admin() ) {
require_once (dirname( __FILE__ ) . '/framework/reon_loader.php');
}
if ( !defined( 'WOOPCD_PARTIALCOD_VERSION' ) ) {
define( 'WOOPCD_PARTIALCOD_VERSION', '1.3.2' );
}
if ( !defined( 'WOOPCD_PARTIALCOD_FILE' ) ) {
define( 'WOOPCD_PARTIALCOD_FILE', __FILE__ );
}
if ( !defined( 'WOOPCD_PARTIALCOD_OPTION_NAME' ) ) {
define( 'WOOPCD_PARTIALCOD_OPTION_NAME', 'woopcd_partialcod' );
}
if ( !defined( 'WOOPCD_PARTIALCOD_HOOKS_INDEX' ) ) {
define( 'WOOPCD_PARTIALCOD_HOOKS_INDEX', 99999 );
}
if ( !class_exists( 'WOOPCD_PartialCOD_Init' ) ) {
class WOOPCD_PartialCOD_Init {
public function __construct() {
add_action( 'plugins_loaded', array( $this, 'plugin_loaded' ), 1 );
add_action( 'before_woocommerce_init', array( $this, 'before_woocommerce_init' ) );
load_plugin_textdomain( 'woopcd-partialcod', false, dirname( plugin_basename( WOOPCD_PARTIALCOD_FILE ) ) . '/languages/' );
}
public function plugin_loaded() {
if ( function_exists( 'WC' ) ) { // Check if WooCommerce is active
$this->init();
} else {
add_action( 'admin_notices', array( $this, 'missing_notice' ) );
}
}
public function before_woocommerce_init() {
// Check for HPOS
if ( !class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
return;
}
// Adds support for HPOS
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', WOOPCD_PARTIALCOD_FILE, true );
}
public function missing_notice() {
echo '<div class="error"><p><strong>' . esc_html__( 'WooCommerce Partial COD - Payment Gateway Restrictions & Fees requires WooCommerce to be installed and activated.', 'woopcd-partialcod' ) . '</strong></p></div>';
}
private function init() {
//Partial COD Main
if ( !class_exists( 'WOOPCD_PartialCOD_Main' ) ) {
include_once ('main/main.php');
WOOPCD_PartialCOD_Main::init();
}
}
}
new WOOPCD_PartialCOD_Init();
}