-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpayment-integration-wompi.php
100 lines (86 loc) · 2.75 KB
/
payment-integration-wompi.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
<?php
/*
Plugin Name: Payment Integration Wompi
Description: Integration of Wompi for Woocommerce
Version: 4.0.1
Author: Saul Morales Pacheco
Author URI: https://saulmoralespa.com
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
WC tested up to: 8.9.3
WC requires at least: 4.0
Requires Plugins: woocommerce
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if(!defined('WOO_WOMPI_PAYMENT_WWP_VERSION')){
define('WOO_WOMPI_PAYMENT_WWP_VERSION', '4.0.1');
}
add_action('plugins_loaded','woo_wompi_payment_wwp_init');
add_action(
'before_woocommerce_init',
function () {
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__ );
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility(
'cart_checkout_blocks',
__FILE__
);
}
}
);
function woo_wompi_payment_wwp_init(): void
{
if (!requeriments_woo_wompi_payment_wwp())
return;
woo_wompi_payment_wwp()->run_wompi();
}
function woo_wompi_payment_wwp_notices( $notice ): void
{
?>
<div class="error notice">
<p><?php echo $notice; ?></p>
</div>
<?php
}
function requeriments_woo_wompi_payment_wwp(): bool
{
if ( !in_array(
'woocommerce/woocommerce.php',
apply_filters( 'active_plugins', get_option( 'active_plugins' ) ),
true
) ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() {
woo_wompi_payment_wwp_notices('Woo Wompi Payment: Woocommerce debe estar instalado y activo');
}
);
}
return false;
}
$shop_currency = get_option('woocommerce_currency');
if (!in_array($shop_currency, array('COP'))){
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
$currency = __('Woo Wompi Payment: Requiere que se encuentre establecida la moneda COP ' ) . sprintf(__('%s' ), '<a href="' . admin_url() . 'admin.php?page=wc-settings&tab=general#s2id_woocommerce_currency">' . __('Haga clic aquí para configurar') . '</a>' );
add_action(
'admin_notices',
function() use($currency) {
woo_wompi_payment_wwp_notices($currency);
}
);
}
return false;
}
return true;
}
function woo_wompi_payment_wwp(){
static $plugin;
if (!isset($plugin)){
require_once ("includes/class-woo-wompi-payment-plugin.php");
$plugin = new Woo_Wompi_Payment(__FILE__, WOO_WOMPI_PAYMENT_WWP_VERSION);
}
return $plugin;
}