-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettle-woocommerce-gateway.php
More file actions
81 lines (67 loc) · 2.75 KB
/
settle-woocommerce-gateway.php
File metadata and controls
81 lines (67 loc) · 2.75 KB
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
<?php
/*
Plugin Name: Settle - WooCommerce Gateway
Plugin URI: http://www.settle.eu
Description: Extends WooCommerce by adding Settle Payment Gateway.
Version: 0.5
Author: Auka AS
License: The MIT License (MIT)
*/
add_action('init', 'settle_woocommerce_real_init', 0);
function settle_woocommerce_real_init() {
$domain = 'settle-woocommerce-gateway';
load_plugin_textdomain($domain, false, dirname(plugin_basename(__FILE__)) . '/languages/');
}
// Include our Gateway Class and register Payment Gateway with WooCommerce
add_action('plugins_loaded', 'settle_woocommerce_init', 0);
function settle_woocommerce_init()
{
// If the parent WC_Payment_Gateway class doesn't exist
// it means WooCommerce is not installed on the site
// so do nothing
if (! class_exists('WC_Payment_Gateway') ) { return;
}
// If we made it this far, then include our Gateway Class
include_once 'classes/settle-woocommerce.php' ;
// Now that we have successfully included our class,
// Lets add it too WooCommerce
add_filter('woocommerce_payment_gateways', 'add_settle_woocommerce_gateway');
function add_settle_woocommerce_gateway( $methods )
{
$methods[] = 'Settle_Woocommerce';
return $methods;
}
add_action('woocommerce_order_actions', 'settle_woocommerce_order_actions');
function settle_woocommerce_order_actions($actions)
{
$actions['settle_capture'] = "Manually capture Settle payment";
return $actions;
}
add_action('woocommerce_order_action_settle_capture', 'settle_manually_capture_payment');
function settle_manually_capture_payment($order)
{
$payment_gateway = new Settle_Woocommerce();
$payment_gateway->manually_capture_payment($order);
}
// If we made it this far, then include our Gateway Class
include_once 'classes/settle-express-woocommerce.php' ;
// Now that we have successfully included our class,
// Lets add it too WooCommerce
add_filter('woocommerce_payment_gateways', 'add_settle_express_woocommerce_gateway');
function add_settle_express_woocommerce_gateway( $methods )
{
$methods[] = 'Settle_Express_Woocommerce';
return $methods;
}
add_action('woocommerce_before_cart', array('Settle_Express_Woocommerce', 'settle_express_cart_button_top'), 14);
}
// Add custom action links
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'settle_woocommerce_action_links');
function settle_woocommerce_action_links( $links )
{
$plugin_links = array(
'<a href="' . admin_url('admin.php?page=wc-settings&tab=checkout') . '">' . __('Settings', 'settle-woocommerce-gateway') . '</a>',
);
// Merge our new link with the default ones
return array_merge($plugin_links, $links);
}