Version Description
- 04/03/2016 =
- Dev - CART & CHECKOUT - Mini Cart - Code refactoring.
- Dev - PAYMENT GATEWAYS - Gateways Currency - Code refactoring.
- Dev - PRICES & CURRENCIES - Currencies - Custom Currencies - Currency Symbol now can be empty.
- Fix - PAYMENT GATEWAYS - Custom Gateways - Additional checks in
init_wc_gateway_wcj_custom_class()
.
Download this release
Release Info
Developer | algoritmika |
Plugin | Booster for WooCommerce |
Version | 2.4.2 |
Comparing to | |
See all releases |
Code changes from version 2.4.1 to 2.4.2
- includes/class-wcj-currencies.php +6 -6
- includes/class-wcj-mini-cart.php +22 -12
- includes/class-wcj-payment-gateways-currency.php +7 -4
- includes/gateways/class-wc-gateway-wcj-custom.php +357 -351
- readme.txt +7 -1
- woocommerce-jetpack.php +12 -24
includes/class-wcj-currencies.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* The WooCommerce Jetpack currencies class stores currencies data.
|
6 |
*
|
7 |
-
* @version 2.4.
|
8 |
* @author Algoritmika Ltd.
|
9 |
*/
|
10 |
|
@@ -17,7 +17,7 @@ class WCJ_Currencies extends WCJ_Module {
|
|
17 |
/**
|
18 |
* Constructor.
|
19 |
*
|
20 |
-
* @version 2.4.
|
21 |
*/
|
22 |
function __construct() {
|
23 |
|
@@ -37,7 +37,7 @@ class WCJ_Currencies extends WCJ_Module {
|
|
37 |
$custom_currency_code = get_option( 'wcj_currency_custom_currency_code_' . $i );
|
38 |
$custom_currency_name = get_option( 'wcj_currency_custom_currency_name_' . $i );
|
39 |
$custom_currency_symbol = get_option( 'wcj_currency_custom_currency_symbol_' . $i );
|
40 |
-
if ( '' != $custom_currency_code && '' != $custom_currency_name && '' != $custom_currency_symbol ) {
|
41 |
$this->currency_names[ $custom_currency_code ] = $custom_currency_name;
|
42 |
$this->currency_symbols[ $custom_currency_code ] = $custom_currency_symbol;
|
43 |
}
|
@@ -101,7 +101,7 @@ class WCJ_Currencies extends WCJ_Module {
|
|
101 |
/**
|
102 |
* get_settings.
|
103 |
*
|
104 |
-
* @version 2.4.
|
105 |
*/
|
106 |
function get_settings() {
|
107 |
|
@@ -159,7 +159,7 @@ class WCJ_Currencies extends WCJ_Module {
|
|
159 |
|
160 |
$settings[] = array(
|
161 |
'title' => __( 'Custom Currency', 'woocommerce-jetpack' ) . ' #' . $i,
|
162 |
-
'desc' => __( 'Currency Name', 'woocommerce-jetpack' ),
|
163 |
'id' => 'wcj_currency_custom_currency_name_' . $i,
|
164 |
'default' => '',
|
165 |
'type' => 'text',
|
@@ -167,7 +167,7 @@ class WCJ_Currencies extends WCJ_Module {
|
|
167 |
|
168 |
$settings[] = array(
|
169 |
'title' => '',
|
170 |
-
'desc' => __( 'Currency Code', 'woocommerce-jetpack' ),
|
171 |
'id' => 'wcj_currency_custom_currency_code_' . $i,
|
172 |
'default' => '',
|
173 |
'type' => 'text',
|
4 |
*
|
5 |
* The WooCommerce Jetpack currencies class stores currencies data.
|
6 |
*
|
7 |
+
* @version 2.4.2
|
8 |
* @author Algoritmika Ltd.
|
9 |
*/
|
10 |
|
17 |
/**
|
18 |
* Constructor.
|
19 |
*
|
20 |
+
* @version 2.4.2
|
21 |
*/
|
22 |
function __construct() {
|
23 |
|
37 |
$custom_currency_code = get_option( 'wcj_currency_custom_currency_code_' . $i );
|
38 |
$custom_currency_name = get_option( 'wcj_currency_custom_currency_name_' . $i );
|
39 |
$custom_currency_symbol = get_option( 'wcj_currency_custom_currency_symbol_' . $i );
|
40 |
+
if ( '' != $custom_currency_code && '' != $custom_currency_name /* && '' != $custom_currency_symbol */ ) {
|
41 |
$this->currency_names[ $custom_currency_code ] = $custom_currency_name;
|
42 |
$this->currency_symbols[ $custom_currency_code ] = $custom_currency_symbol;
|
43 |
}
|
101 |
/**
|
102 |
* get_settings.
|
103 |
*
|
104 |
+
* @version 2.4.2
|
105 |
*/
|
106 |
function get_settings() {
|
107 |
|
159 |
|
160 |
$settings[] = array(
|
161 |
'title' => __( 'Custom Currency', 'woocommerce-jetpack' ) . ' #' . $i,
|
162 |
+
'desc' => __( 'Currency Name (required)', 'woocommerce-jetpack' ),
|
163 |
'id' => 'wcj_currency_custom_currency_name_' . $i,
|
164 |
'default' => '',
|
165 |
'type' => 'text',
|
167 |
|
168 |
$settings[] = array(
|
169 |
'title' => '',
|
170 |
+
'desc' => __( 'Currency Code (required)', 'woocommerce-jetpack' ),
|
171 |
'id' => 'wcj_currency_custom_currency_code_' . $i,
|
172 |
'default' => '',
|
173 |
'type' => 'text',
|
includes/class-wcj-mini-cart.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* The WooCommerce Jetpack Mini Cart class.
|
6 |
*
|
7 |
-
* @version 2.2
|
8 |
* @since 2.2.0
|
9 |
* @author Algoritmika Ltd.
|
10 |
*/
|
@@ -35,6 +35,8 @@ class WCJ_Mini_Cart extends WCJ_Module {
|
|
35 |
|
36 |
/**
|
37 |
* get_settings.
|
|
|
|
|
38 |
*/
|
39 |
function get_settings() {
|
40 |
|
@@ -42,19 +44,25 @@ class WCJ_Mini_Cart extends WCJ_Module {
|
|
42 |
$settings = array();
|
43 |
|
44 |
// Mini Cart Custom Info Options
|
45 |
-
$settings[] = array(
|
|
|
|
|
|
|
|
|
46 |
|
47 |
$settings[] = array(
|
48 |
'title' => __( 'Total Blocks', 'woocommerce-jetpack' ),
|
49 |
'id' => 'wcj_mini_cart_custom_info_total_number',
|
50 |
'default' => 1,
|
51 |
'type' => 'custom_number',
|
52 |
-
//'type' => 'number',
|
53 |
'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
|
54 |
'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
|
55 |
);
|
56 |
|
57 |
-
$settings[] = array(
|
|
|
|
|
|
|
58 |
|
59 |
$total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_mini_cart_custom_info_total_number', 1 ) );
|
60 |
|
@@ -62,11 +70,14 @@ class WCJ_Mini_Cart extends WCJ_Module {
|
|
62 |
|
63 |
$settings = array_merge( $settings, array(
|
64 |
|
65 |
-
array(
|
|
|
|
|
|
|
|
|
66 |
|
67 |
array(
|
68 |
'title' => __( 'Content', 'woocommerce-jetpack' ),
|
69 |
-
//'desc' => __( 'Content', 'woocommerce-jetpack' ),
|
70 |
'id' => 'wcj_mini_cart_custom_info_content_' . $i,
|
71 |
'default' => '[wcj_cart_items_total_weight before="Total weight: " after=" kg"]',
|
72 |
'type' => 'textarea',
|
@@ -75,7 +86,6 @@ class WCJ_Mini_Cart extends WCJ_Module {
|
|
75 |
|
76 |
array(
|
77 |
'title' => __( 'Position', 'woocommerce-jetpack' ),
|
78 |
-
//'desc' => __( 'Position', 'woocommerce-jetpack' ),
|
79 |
'id' => 'wcj_mini_cart_custom_info_hook_' . $i,
|
80 |
'default' => 'woocommerce_after_mini_cart',
|
81 |
'type' => 'select',
|
@@ -89,20 +99,20 @@ class WCJ_Mini_Cart extends WCJ_Module {
|
|
89 |
|
90 |
array(
|
91 |
'title' => __( 'Priority', 'woocommerce-jetpack' ),
|
92 |
-
//'desc' => __( 'Priority', 'woocommerce-jetpack' ),
|
93 |
'id' => 'wcj_mini_cart_custom_info_priority_' . $i,
|
94 |
'default' => 10,
|
95 |
'type' => 'number',
|
96 |
'css' => 'width:250px;',
|
97 |
),
|
98 |
|
99 |
-
array(
|
|
|
|
|
|
|
100 |
) );
|
101 |
}
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
return $this->add_enable_module_setting( $settings );
|
106 |
}
|
107 |
|
108 |
/**
|
4 |
*
|
5 |
* The WooCommerce Jetpack Mini Cart class.
|
6 |
*
|
7 |
+
* @version 2.4.2
|
8 |
* @since 2.2.0
|
9 |
* @author Algoritmika Ltd.
|
10 |
*/
|
35 |
|
36 |
/**
|
37 |
* get_settings.
|
38 |
+
*
|
39 |
+
* @version 2.4.2
|
40 |
*/
|
41 |
function get_settings() {
|
42 |
|
44 |
$settings = array();
|
45 |
|
46 |
// Mini Cart Custom Info Options
|
47 |
+
$settings[] = array(
|
48 |
+
'title' => __( 'Mini Cart Custom Info Blocks', 'woocommerce-jetpack' ),
|
49 |
+
'type' => 'title',
|
50 |
+
'id' => 'wcj_mini_cart_custom_info_options',
|
51 |
+
);
|
52 |
|
53 |
$settings[] = array(
|
54 |
'title' => __( 'Total Blocks', 'woocommerce-jetpack' ),
|
55 |
'id' => 'wcj_mini_cart_custom_info_total_number',
|
56 |
'default' => 1,
|
57 |
'type' => 'custom_number',
|
|
|
58 |
'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
|
59 |
'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
|
60 |
);
|
61 |
|
62 |
+
$settings[] = array(
|
63 |
+
'type' => 'sectionend',
|
64 |
+
'id' => 'wcj_mini_cart_custom_info_options',
|
65 |
+
);
|
66 |
|
67 |
$total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_mini_cart_custom_info_total_number', 1 ) );
|
68 |
|
70 |
|
71 |
$settings = array_merge( $settings, array(
|
72 |
|
73 |
+
array(
|
74 |
+
'title' => __( 'Info Block', 'woocommerce-jetpack' ) . ' #' . $i,
|
75 |
+
'type' => 'title',
|
76 |
+
'id' => 'wcj_mini_cart_custom_info_options_' . $i,
|
77 |
+
),
|
78 |
|
79 |
array(
|
80 |
'title' => __( 'Content', 'woocommerce-jetpack' ),
|
|
|
81 |
'id' => 'wcj_mini_cart_custom_info_content_' . $i,
|
82 |
'default' => '[wcj_cart_items_total_weight before="Total weight: " after=" kg"]',
|
83 |
'type' => 'textarea',
|
86 |
|
87 |
array(
|
88 |
'title' => __( 'Position', 'woocommerce-jetpack' ),
|
|
|
89 |
'id' => 'wcj_mini_cart_custom_info_hook_' . $i,
|
90 |
'default' => 'woocommerce_after_mini_cart',
|
91 |
'type' => 'select',
|
99 |
|
100 |
array(
|
101 |
'title' => __( 'Priority', 'woocommerce-jetpack' ),
|
|
|
102 |
'id' => 'wcj_mini_cart_custom_info_priority_' . $i,
|
103 |
'default' => 10,
|
104 |
'type' => 'number',
|
105 |
'css' => 'width:250px;',
|
106 |
),
|
107 |
|
108 |
+
array(
|
109 |
+
'type' => 'sectionend',
|
110 |
+
'id' => 'wcj_mini_cart_custom_info_options_' . $i,
|
111 |
+
),
|
112 |
) );
|
113 |
}
|
114 |
|
115 |
+
return $this->add_standard_settings( $settings );
|
|
|
|
|
116 |
}
|
117 |
|
118 |
/**
|
includes/class-wcj-payment-gateways-currency.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* The WooCommerce Jetpack Payment Gateways Currency class.
|
6 |
*
|
7 |
-
* @version 2.
|
8 |
* @since 2.3.0
|
9 |
* @author Algoritmika Ltd.
|
10 |
*/
|
@@ -148,10 +148,13 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
|
|
148 |
|
149 |
/**
|
150 |
* get_settings.
|
|
|
|
|
151 |
*/
|
152 |
function get_settings() {
|
153 |
$settings = array();
|
154 |
$settings = apply_filters( 'wcj_payment_gateways_currency_settings', $settings );
|
|
|
155 |
return $this->add_enable_module_setting( $settings );
|
156 |
}
|
157 |
|
@@ -183,7 +186,7 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
|
|
183 |
/**
|
184 |
* add_currency_settings.
|
185 |
*
|
186 |
-
* @version 2.4.
|
187 |
*/
|
188 |
function add_currency_settings( $settings ) {
|
189 |
|
@@ -191,7 +194,7 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
|
|
191 |
'title' => __( 'Payment Gateways Currency Options', 'woocommerce-jetpack' ),
|
192 |
'type' => 'title',
|
193 |
'desc' => __( 'This section lets you set different currency for each payment gateway.', 'woocommerce-jetpack' ),
|
194 |
-
'id' => 'wcj_payment_gateways_currency_options'
|
195 |
);
|
196 |
|
197 |
$currency_from = get_woocommerce_currency();
|
@@ -260,7 +263,7 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
|
|
260 |
|
261 |
$settings[] = array(
|
262 |
'type' => 'sectionend',
|
263 |
-
'id' => 'wcj_payment_gateways_currency_options'
|
264 |
);
|
265 |
|
266 |
return $settings;
|
4 |
*
|
5 |
* The WooCommerce Jetpack Payment Gateways Currency class.
|
6 |
*
|
7 |
+
* @version 2.4.2
|
8 |
* @since 2.3.0
|
9 |
* @author Algoritmika Ltd.
|
10 |
*/
|
148 |
|
149 |
/**
|
150 |
* get_settings.
|
151 |
+
*
|
152 |
+
* @version 2.4.2
|
153 |
*/
|
154 |
function get_settings() {
|
155 |
$settings = array();
|
156 |
$settings = apply_filters( 'wcj_payment_gateways_currency_settings', $settings );
|
157 |
+
// return $this->add_standard_settings( $settings ); // TODO
|
158 |
return $this->add_enable_module_setting( $settings );
|
159 |
}
|
160 |
|
186 |
/**
|
187 |
* add_currency_settings.
|
188 |
*
|
189 |
+
* @version 2.4.2
|
190 |
*/
|
191 |
function add_currency_settings( $settings ) {
|
192 |
|
194 |
'title' => __( 'Payment Gateways Currency Options', 'woocommerce-jetpack' ),
|
195 |
'type' => 'title',
|
196 |
'desc' => __( 'This section lets you set different currency for each payment gateway.', 'woocommerce-jetpack' ),
|
197 |
+
'id' => 'wcj_payment_gateways_currency_options',
|
198 |
);
|
199 |
|
200 |
$currency_from = get_woocommerce_currency();
|
263 |
|
264 |
$settings[] = array(
|
265 |
'type' => 'sectionend',
|
266 |
+
'id' => 'wcj_payment_gateways_currency_options',
|
267 |
);
|
268 |
|
269 |
return $settings;
|
includes/gateways/class-wc-gateway-wcj-custom.php
CHANGED
@@ -4,399 +4,405 @@
|
|
4 |
*
|
5 |
* The WooCommerce Jetpack Custom Payment Gateway class.
|
6 |
*
|
7 |
-
* @version 2.4.
|
8 |
* @author Algoritmika Ltd.
|
9 |
*/
|
10 |
|
11 |
add_action( 'plugins_loaded', 'init_wc_gateway_wcj_custom_class' );
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
class WC_Gateway_WCJ_Custom_Template extends WC_Payment_Gateway {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* set_icon
|
19 |
-
*/
|
20 |
-
/* public function set_icon() {
|
21 |
-
$icon_url = get_option( 'wcj_payment_gateways_icons_woocommerce_wcj_custom_icon', '' );
|
22 |
-
if ( $icon_url === '' )
|
23 |
-
return $this->get_option( 'icon', '' );
|
24 |
-
return $icon_url;
|
25 |
-
} */
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Initialise Gateway Settings Form Fields
|
29 |
-
*
|
30 |
-
* @version 2.4.0
|
31 |
-
*/
|
32 |
-
public function init_form_fields() {
|
33 |
-
global $woocommerce;
|
34 |
-
|
35 |
-
$shipping_methods = array();
|
36 |
-
|
37 |
-
if ( is_admin() ) {
|
38 |
-
foreach ( WC()->shipping->load_shipping_methods() as $method ) {
|
39 |
-
$shipping_methods[ $method->id ] = $method->get_title();
|
40 |
-
}
|
41 |
-
}
|
42 |
|
43 |
-
|
44 |
-
$icon_url = $this->get_option( 'icon', '' );//apply_filters( 'woocommerce_wcj_custom_icon', $this->get_option( 'icon', '' ) );
|
45 |
-
if ( $icon_url !== '' ) {
|
46 |
-
//$desc = '<img src="' . $icon_url . '" alt="WooJetpack Custom" title="WooJetpack Custom" />';
|
47 |
-
$desc = '<img src="' . $icon_url . '" alt="' . $this->title . '" title="' . $this->title . '" />';
|
48 |
-
}
|
49 |
|
50 |
-
|
51 |
-
'enabled' => array(
|
52 |
-
'title' => __( 'Enable/Disable', 'woocommerce' ),
|
53 |
-
'type' => 'checkbox',
|
54 |
-
'label' => __( 'Enable Custom Payment', 'woocommerce' ),
|
55 |
-
'default' => 'no',
|
56 |
-
),
|
57 |
-
|
58 |
-
'title' => array(
|
59 |
-
'title' => __( 'Title', 'woocommerce' ),
|
60 |
-
'type' => 'text',
|
61 |
-
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
|
62 |
-
'default' => __( 'Custom Payment', 'woocommerce' ),
|
63 |
-
'desc_tip' => true,
|
64 |
-
),
|
65 |
-
|
66 |
-
'description' => array(
|
67 |
-
'title' => __( 'Description', 'woocommerce' ),
|
68 |
-
'type' => 'textarea',
|
69 |
-
'description' => __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ),
|
70 |
-
'default' => __( 'Custom Payment Description.', 'woocommerce' ),
|
71 |
-
'desc_tip' => true,
|
72 |
-
),
|
73 |
-
|
74 |
-
'instructions' => array(
|
75 |
-
'title' => __( 'Instructions', 'woocommerce' ),
|
76 |
-
'type' => 'textarea',
|
77 |
-
'description' => __( 'Instructions that will be added to the thank you page.', 'woocommerce-jetpack' ),
|
78 |
-
'default' => '',
|
79 |
-
'desc_tip' => true,
|
80 |
-
),
|
81 |
-
|
82 |
-
'instructions_in_email' => array(
|
83 |
-
'title' => __( 'Email Instructions', 'woocommerce' ),
|
84 |
-
'type' => 'textarea',
|
85 |
-
'description' => __( 'Instructions that will be added to the emails.', 'woocommerce-jetpack' ),
|
86 |
-
'default' => '',
|
87 |
-
'desc_tip' => true,
|
88 |
-
),
|
89 |
-
|
90 |
-
'icon' => array(
|
91 |
-
'title' => __( 'Icon', 'woocommerce-jetpack' ),
|
92 |
-
'type' => 'text',
|
93 |
-
'desc_tip' => __( 'If you want to show an image next to the gateway\'s name on the frontend, enter a URL to an image.', 'woocommerce-jetpack' ),
|
94 |
-
'default' => '',
|
95 |
-
'description' => $desc,
|
96 |
-
'css' => 'min-width:300px;width:50%;',
|
97 |
-
),
|
98 |
-
|
99 |
-
'min_amount' => array(
|
100 |
-
'title' => __( 'Minimum order amount', 'woocommerce-jetpack' ),
|
101 |
-
'type' => 'number',
|
102 |
-
'desc_tip' => __( 'If you want to set minimum order amount to show this gateway on frontend, enter a number here. Set to 0 to disable.', 'woocommerce-jetpack' ),
|
103 |
-
'default' => 0,
|
104 |
-
'description' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
|
105 |
-
'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
|
106 |
-
),
|
107 |
-
|
108 |
-
'enable_for_methods' => array(
|
109 |
-
'title' => __( 'Enable for shipping methods', 'woocommerce' ),
|
110 |
-
'type' => 'multiselect',
|
111 |
-
'class' => 'chosen_select',
|
112 |
-
'css' => 'width: 450px;',
|
113 |
-
'default' => '',
|
114 |
-
'description' => __( 'If gateway is only available for certain shipping methods, set it up here. Leave blank to enable for all methods.', 'woocommerce-jetpack' ),
|
115 |
-
'options' => $shipping_methods,
|
116 |
-
'desc_tip' => true,
|
117 |
-
'custom_attributes' => array( 'data-placeholder' => __( 'Select shipping methods', 'woocommerce' ) ),
|
118 |
-
),
|
119 |
-
|
120 |
-
'enable_for_virtual' => array(
|
121 |
-
'title' => __( 'Enable for virtual orders', 'woocommerce' ),
|
122 |
-
'label' => __( 'Enable gateway if the order is virtual', 'woocommerce-jetpack' ),
|
123 |
-
'type' => 'checkbox',
|
124 |
-
'default' => 'yes'
|
125 |
-
),
|
126 |
-
|
127 |
-
'default_order_status' => array(
|
128 |
-
'title' => __( 'Default Order Status', 'woocommerce-jetpack' ),
|
129 |
-
'description' => __( 'Enable Custom Statuses feature to add custom statuses to the list.', 'woocommerce-jetpack' ),
|
130 |
-
'default' => apply_filters( 'woocommerce_default_order_status', 'pending' ),
|
131 |
-
'type' => 'select',
|
132 |
-
'options' => $this->get_order_statuses(),
|
133 |
-
),
|
134 |
-
|
135 |
-
'send_email_to_admin' => array(
|
136 |
-
'title' => __( 'Send Additional Emails', 'woocommerce-jetpack' ),
|
137 |
-
'label' => __( 'Send to Admin', 'woocommerce-jetpack' ),
|
138 |
-
// 'description' => __( 'This may help if you are using pending or custom default status and not getting new order emails.', 'woocommerce-jetpack' ),
|
139 |
-
'default' => 'no',
|
140 |
-
'type' => 'checkbox',
|
141 |
-
),
|
142 |
-
|
143 |
-
'send_email_to_customer' => array(
|
144 |
-
'title' => '',//__( 'Send Additional Email to Customer', 'woocommerce-jetpack' ),
|
145 |
-
'label' => __( 'Send to Customer', 'woocommerce-jetpack' ),
|
146 |
-
'description' => __( 'This may help if you are using pending or custom default status and not getting new order emails.', 'woocommerce-jetpack' ),
|
147 |
-
'default' => 'no',
|
148 |
-
'type' => 'checkbox',
|
149 |
-
),
|
150 |
-
|
151 |
-
'custom_return_url' => array(
|
152 |
-
'title' => __( 'Custom Return URL (Thank You Page)', 'woocommerce-jetpack' ),
|
153 |
-
'label' => __( 'URL', 'woocommerce-jetpack' ),
|
154 |
-
'desc_tip' => __( 'Enter full URL with http(s).', 'woocommerce-jetpack' ),
|
155 |
-
'description' => __( 'Optional. Leave blank to use default URL.', 'woocommerce-jetpack' ),
|
156 |
-
'default' => '',
|
157 |
-
'type' => 'text',
|
158 |
-
),
|
159 |
-
);
|
160 |
-
|
161 |
-
if ( 1 != $this->id_count ) {
|
162 |
-
$this->form_fields['enabled']['description'] = apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' );
|
163 |
-
$this->form_fields['enabled']['custom_attributes'] = apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' );
|
164 |
-
}
|
165 |
-
}
|
166 |
|
167 |
-
|
168 |
-
* get_order_statuses.
|
169 |
-
*/
|
170 |
-
function get_order_statuses() {
|
171 |
-
$result = array();
|
172 |
-
$statuses = function_exists( 'wc_get_order_statuses' ) ? wc_get_order_statuses() : array();
|
173 |
-
foreach( $statuses as $status => $status_name ) {
|
174 |
-
$result[ substr( $status, 3 ) ] = $statuses[ $status ];
|
175 |
-
}
|
176 |
-
return $result;
|
177 |
-
}
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
192 |
|
193 |
-
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
}
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
|
205 |
-
//
|
206 |
-
$
|
207 |
|
208 |
-
if (
|
209 |
-
|
210 |
-
|
|
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
}
|
216 |
-
}
|
217 |
-
}
|
218 |
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
|
|
|
|
223 |
}
|
224 |
-
}
|
225 |
-
}
|
226 |
|
227 |
-
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
|
239 |
-
|
240 |
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
|
256 |
-
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
}
|
263 |
-
}
|
264 |
|
265 |
-
|
266 |
-
return false;
|
267 |
}
|
268 |
-
}
|
269 |
-
|
270 |
-
return parent::is_available();
|
271 |
-
}
|
272 |
|
273 |
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
|
320 |
-
|
321 |
-
|
322 |
|
323 |
-
|
324 |
-
|
325 |
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
|
|
|
|
|
|
|
|
398 |
}
|
399 |
-
return $methods;
|
400 |
}
|
401 |
-
|
402 |
-
}
|
4 |
*
|
5 |
* The WooCommerce Jetpack Custom Payment Gateway class.
|
6 |
*
|
7 |
+
* @version 2.4.2
|
8 |
* @author Algoritmika Ltd.
|
9 |
*/
|
10 |
|
11 |
add_action( 'plugins_loaded', 'init_wc_gateway_wcj_custom_class' );
|
12 |
|
13 |
+
if ( ! function_exists( 'init_wc_gateway_wcj_custom_class' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
function init_wc_gateway_wcj_custom_class() {
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
if ( class_exists( 'WC_Payment_Gateway' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
class WC_Gateway_WCJ_Custom_Template extends WC_Payment_Gateway {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
/**
|
22 |
+
* set_icon
|
23 |
+
*/
|
24 |
+
/* public function set_icon() {
|
25 |
+
$icon_url = get_option( 'wcj_payment_gateways_icons_woocommerce_wcj_custom_icon', '' );
|
26 |
+
if ( $icon_url === '' )
|
27 |
+
return $this->get_option( 'icon', '' );
|
28 |
+
return $icon_url;
|
29 |
+
} */
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Initialise Gateway Settings Form Fields
|
33 |
+
*
|
34 |
+
* @version 2.4.0
|
35 |
+
*/
|
36 |
+
public function init_form_fields() {
|
37 |
+
global $woocommerce;
|
38 |
|
39 |
+
$shipping_methods = array();
|
40 |
+
|
41 |
+
if ( is_admin() ) {
|
42 |
+
foreach ( WC()->shipping->load_shipping_methods() as $method ) {
|
43 |
+
$shipping_methods[ $method->id ] = $method->get_title();
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
$desc = '';
|
48 |
+
$icon_url = $this->get_option( 'icon', '' );//apply_filters( 'woocommerce_wcj_custom_icon', $this->get_option( 'icon', '' ) );
|
49 |
+
if ( $icon_url !== '' ) {
|
50 |
+
//$desc = '<img src="' . $icon_url . '" alt="WooJetpack Custom" title="WooJetpack Custom" />';
|
51 |
+
$desc = '<img src="' . $icon_url . '" alt="' . $this->title . '" title="' . $this->title . '" />';
|
52 |
+
}
|
53 |
+
|
54 |
+
$this->form_fields = array(
|
55 |
+
'enabled' => array(
|
56 |
+
'title' => __( 'Enable/Disable', 'woocommerce' ),
|
57 |
+
'type' => 'checkbox',
|
58 |
+
'label' => __( 'Enable Custom Payment', 'woocommerce' ),
|
59 |
+
'default' => 'no',
|
60 |
+
),
|
61 |
+
|
62 |
+
'title' => array(
|
63 |
+
'title' => __( 'Title', 'woocommerce' ),
|
64 |
+
'type' => 'text',
|
65 |
+
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
|
66 |
+
'default' => __( 'Custom Payment', 'woocommerce' ),
|
67 |
+
'desc_tip' => true,
|
68 |
+
),
|
69 |
+
|
70 |
+
'description' => array(
|
71 |
+
'title' => __( 'Description', 'woocommerce' ),
|
72 |
+
'type' => 'textarea',
|
73 |
+
'description' => __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ),
|
74 |
+
'default' => __( 'Custom Payment Description.', 'woocommerce' ),
|
75 |
+
'desc_tip' => true,
|
76 |
+
),
|
77 |
+
|
78 |
+
'instructions' => array(
|
79 |
+
'title' => __( 'Instructions', 'woocommerce' ),
|
80 |
+
'type' => 'textarea',
|
81 |
+
'description' => __( 'Instructions that will be added to the thank you page.', 'woocommerce-jetpack' ),
|
82 |
+
'default' => '',
|
83 |
+
'desc_tip' => true,
|
84 |
+
),
|
85 |
+
|
86 |
+
'instructions_in_email' => array(
|
87 |
+
'title' => __( 'Email Instructions', 'woocommerce' ),
|
88 |
+
'type' => 'textarea',
|
89 |
+
'description' => __( 'Instructions that will be added to the emails.', 'woocommerce-jetpack' ),
|
90 |
+
'default' => '',
|
91 |
+
'desc_tip' => true,
|
92 |
+
),
|
93 |
+
|
94 |
+
'icon' => array(
|
95 |
+
'title' => __( 'Icon', 'woocommerce-jetpack' ),
|
96 |
+
'type' => 'text',
|
97 |
+
'desc_tip' => __( 'If you want to show an image next to the gateway\'s name on the frontend, enter a URL to an image.', 'woocommerce-jetpack' ),
|
98 |
+
'default' => '',
|
99 |
+
'description' => $desc,
|
100 |
+
'css' => 'min-width:300px;width:50%;',
|
101 |
+
),
|
102 |
+
|
103 |
+
'min_amount' => array(
|
104 |
+
'title' => __( 'Minimum order amount', 'woocommerce-jetpack' ),
|
105 |
+
'type' => 'number',
|
106 |
+
'desc_tip' => __( 'If you want to set minimum order amount to show this gateway on frontend, enter a number here. Set to 0 to disable.', 'woocommerce-jetpack' ),
|
107 |
+
'default' => 0,
|
108 |
+
'description' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
|
109 |
+
'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
|
110 |
+
),
|
111 |
+
|
112 |
+
'enable_for_methods' => array(
|
113 |
+
'title' => __( 'Enable for shipping methods', 'woocommerce' ),
|
114 |
+
'type' => 'multiselect',
|
115 |
+
'class' => 'chosen_select',
|
116 |
+
'css' => 'width: 450px;',
|
117 |
+
'default' => '',
|
118 |
+
'description' => __( 'If gateway is only available for certain shipping methods, set it up here. Leave blank to enable for all methods.', 'woocommerce-jetpack' ),
|
119 |
+
'options' => $shipping_methods,
|
120 |
+
'desc_tip' => true,
|
121 |
+
'custom_attributes' => array( 'data-placeholder' => __( 'Select shipping methods', 'woocommerce' ) ),
|
122 |
+
),
|
123 |
+
|
124 |
+
'enable_for_virtual' => array(
|
125 |
+
'title' => __( 'Enable for virtual orders', 'woocommerce' ),
|
126 |
+
'label' => __( 'Enable gateway if the order is virtual', 'woocommerce-jetpack' ),
|
127 |
+
'type' => 'checkbox',
|
128 |
+
'default' => 'yes'
|
129 |
+
),
|
130 |
+
|
131 |
+
'default_order_status' => array(
|
132 |
+
'title' => __( 'Default Order Status', 'woocommerce-jetpack' ),
|
133 |
+
'description' => __( 'Enable Custom Statuses feature to add custom statuses to the list.', 'woocommerce-jetpack' ),
|
134 |
+
'default' => apply_filters( 'woocommerce_default_order_status', 'pending' ),
|
135 |
+
'type' => 'select',
|
136 |
+
'options' => $this->get_order_statuses(),
|
137 |
+
),
|
138 |
+
|
139 |
+
'send_email_to_admin' => array(
|
140 |
+
'title' => __( 'Send Additional Emails', 'woocommerce-jetpack' ),
|
141 |
+
'label' => __( 'Send to Admin', 'woocommerce-jetpack' ),
|
142 |
+
// 'description' => __( 'This may help if you are using pending or custom default status and not getting new order emails.', 'woocommerce-jetpack' ),
|
143 |
+
'default' => 'no',
|
144 |
+
'type' => 'checkbox',
|
145 |
+
),
|
146 |
+
|
147 |
+
'send_email_to_customer' => array(
|
148 |
+
'title' => '',//__( 'Send Additional Email to Customer', 'woocommerce-jetpack' ),
|
149 |
+
'label' => __( 'Send to Customer', 'woocommerce-jetpack' ),
|
150 |
+
'description' => __( 'This may help if you are using pending or custom default status and not getting new order emails.', 'woocommerce-jetpack' ),
|
151 |
+
'default' => 'no',
|
152 |
+
'type' => 'checkbox',
|
153 |
+
),
|
154 |
+
|
155 |
+
'custom_return_url' => array(
|
156 |
+
'title' => __( 'Custom Return URL (Thank You Page)', 'woocommerce-jetpack' ),
|
157 |
+
'label' => __( 'URL', 'woocommerce-jetpack' ),
|
158 |
+
'desc_tip' => __( 'Enter full URL with http(s).', 'woocommerce-jetpack' ),
|
159 |
+
'description' => __( 'Optional. Leave blank to use default URL.', 'woocommerce-jetpack' ),
|
160 |
+
'default' => '',
|
161 |
+
'type' => 'text',
|
162 |
+
),
|
163 |
+
);
|
164 |
+
|
165 |
+
if ( 1 != $this->id_count ) {
|
166 |
+
$this->form_fields['enabled']['description'] = apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' );
|
167 |
+
$this->form_fields['enabled']['custom_attributes'] = apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' );
|
168 |
+
}
|
169 |
+
}
|
170 |
|
171 |
+
/**
|
172 |
+
* get_order_statuses.
|
173 |
+
*/
|
174 |
+
function get_order_statuses() {
|
175 |
+
$result = array();
|
176 |
+
$statuses = function_exists( 'wc_get_order_statuses' ) ? wc_get_order_statuses() : array();
|
177 |
+
foreach( $statuses as $status => $status_name ) {
|
178 |
+
$result[ substr( $status, 3 ) ] = $statuses[ $status ];
|
179 |
+
}
|
180 |
+
return $result;
|
181 |
}
|
182 |
|
183 |
+
/**
|
184 |
+
* Check If The Gateway Is Available For Use
|
185 |
+
*
|
186 |
+
* @version 2.3.9
|
187 |
+
* @return bool
|
188 |
+
*/
|
189 |
+
public function is_available() {
|
190 |
+
// Check min amount
|
191 |
+
$min_amount = apply_filters( 'wcj_get_option_filter', 0, $this->min_amount );
|
192 |
+
if ( $min_amount > 0 ) {
|
193 |
+
if ( WC()->cart->total < $min_amount )
|
194 |
+
return false;
|
195 |
+
}
|
196 |
|
197 |
+
// Check shipping methods and is virtual
|
198 |
+
$order = null;
|
199 |
|
200 |
+
if ( ! $this->enable_for_virtual ) {
|
201 |
+
if ( WC()->cart && ! WC()->cart->needs_shipping() ) {
|
202 |
+
return false;
|
203 |
+
}
|
204 |
|
205 |
+
if ( is_page( wc_get_page_id( 'checkout' ) ) && 0 < get_query_var( 'order-pay' ) ) {
|
206 |
+
$order_id = absint( get_query_var( 'order-pay' ) );
|
207 |
+
$order = new WC_Order( $order_id );
|
208 |
+
|
209 |
+
// Test if order needs shipping.
|
210 |
+
$needs_shipping = false;
|
211 |
+
|
212 |
+
if ( 0 < sizeof( $order->get_items() ) ) {
|
213 |
+
foreach ( $order->get_items() as $item ) {
|
214 |
+
$_product = $order->get_product_from_item( $item );
|
215 |
+
|
216 |
+
if ( $_product->needs_shipping() ) {
|
217 |
+
$needs_shipping = true;
|
218 |
+
break;
|
219 |
+
}
|
220 |
+
}
|
221 |
}
|
|
|
|
|
222 |
|
223 |
+
$needs_shipping = apply_filters( 'woocommerce_cart_needs_shipping', $needs_shipping );
|
224 |
|
225 |
+
if ( $needs_shipping ) {
|
226 |
+
return false;
|
227 |
+
}
|
228 |
+
}
|
229 |
}
|
|
|
|
|
230 |
|
231 |
+
if ( ! empty( $this->enable_for_methods ) ) {
|
232 |
|
233 |
+
// Only apply if all packages are being shipped via ...
|
234 |
+
$session_object = WC()->session;
|
235 |
+
$chosen_shipping_methods_session = ( is_object( $session_object ) ) ? $session_object->get( 'chosen_shipping_methods' ) : null;
|
236 |
|
237 |
+
if ( isset( $chosen_shipping_methods_session ) ) {
|
238 |
+
$chosen_shipping_methods = array_unique( $chosen_shipping_methods_session );
|
239 |
+
} else {
|
240 |
+
$chosen_shipping_methods = array();
|
241 |
+
}
|
242 |
|
243 |
+
$check_method = false;
|
244 |
|
245 |
+
if ( is_object( $order ) ) {
|
246 |
+
if ( $order->shipping_method ) {
|
247 |
+
$check_method = $order->shipping_method;
|
248 |
+
}
|
249 |
|
250 |
+
} elseif ( empty( $chosen_shipping_methods ) || sizeof( $chosen_shipping_methods ) > 1 ) {
|
251 |
+
$check_method = false;
|
252 |
+
} elseif ( sizeof( $chosen_shipping_methods ) == 1 ) {
|
253 |
+
$check_method = $chosen_shipping_methods[0];
|
254 |
+
}
|
255 |
|
256 |
+
if ( ! $check_method ) {
|
257 |
+
return false;
|
258 |
+
}
|
259 |
|
260 |
+
$found = false;
|
261 |
|
262 |
+
foreach ( $this->enable_for_methods as $method_id ) {
|
263 |
+
if ( strpos( $check_method, $method_id ) === 0 ) {
|
264 |
+
$found = true;
|
265 |
+
break;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
if ( ! $found ) {
|
270 |
+
return false;
|
271 |
+
}
|
272 |
}
|
|
|
273 |
|
274 |
+
return parent::is_available();
|
|
|
275 |
}
|
|
|
|
|
|
|
|
|
276 |
|
277 |
|
278 |
+
/**
|
279 |
+
* Output for the order received page.
|
280 |
+
*/
|
281 |
+
public function thankyou_page() {
|
282 |
+
if ( $this->instructions )
|
283 |
+
echo do_shortcode( wpautop( wptexturize( $this->instructions ) ) );
|
284 |
+
}
|
285 |
|
286 |
+
/**
|
287 |
+
* Add content to the WC emails.
|
288 |
+
*
|
289 |
+
* @access public
|
290 |
+
* @param WC_Order $order
|
291 |
+
* @param bool $sent_to_admin
|
292 |
+
* @param bool $plain_text
|
293 |
+
*/
|
294 |
+
public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {
|
295 |
+
//if ( $this->instructions_in_email && ! $sent_to_admin && $this->id === $order->payment_method && 'on-hold' === $order->status ) {
|
296 |
+
if ( $this->instructions_in_email && ! $sent_to_admin && $this->id === $order->payment_method && $this->default_order_status === $order->status ) {
|
297 |
+
echo do_shortcode( wpautop( wptexturize( $this->instructions_in_email ) ) . PHP_EOL );
|
298 |
+
}
|
299 |
+
}
|
300 |
|
301 |
+
/**
|
302 |
+
* Process the payment and return the result
|
303 |
+
*
|
304 |
+
* @version 2.4.0
|
305 |
+
* @param int $order_id
|
306 |
+
* @return array
|
307 |
+
*/
|
308 |
+
public function process_payment( $order_id ) {
|
309 |
+
|
310 |
+
$order = new WC_Order( $order_id );
|
311 |
+
|
312 |
+
// Mark as on-hold (we're awaiting the payment)
|
313 |
+
//$order->update_status( 'on-hold', __( 'Awaiting payment', 'woocommerce' ) );
|
314 |
+
$statuses = $this->get_order_statuses();
|
315 |
+
$note = isset( $statuses[ $this->default_order_status ] ) ? $statuses[ $this->default_order_status ] : '';
|
316 |
+
$order->update_status( $this->default_order_status, $note );
|
317 |
+
|
318 |
+
if ( 'yes' === $this->send_email_to_admin || 'yes' === $this->send_email_to_customer ) {
|
319 |
+
$woocommerce_mailer = WC()->mailer();
|
320 |
+
if ( 'yes' === $this->send_email_to_admin ) $woocommerce_mailer->emails['WC_Email_New_Order']->trigger( $order_id );
|
321 |
+
if ( 'yes' === $this->send_email_to_customer ) $woocommerce_mailer->emails['WC_Email_Customer_Processing_Order']->trigger( $order_id );
|
322 |
+
}
|
323 |
|
324 |
+
// Reduce stock levels
|
325 |
+
$order->reduce_order_stock();
|
326 |
|
327 |
+
// Remove cart
|
328 |
+
WC()->cart->empty_cart();
|
329 |
|
330 |
+
// Return thankyou redirect
|
331 |
+
return array(
|
332 |
+
'result' => 'success',
|
333 |
+
'redirect' => ( '' == $this->custom_return_url ) ? $this->get_return_url( $order ) : $this->custom_return_url,
|
334 |
+
);
|
335 |
+
}
|
336 |
|
337 |
+
/**
|
338 |
+
* init.
|
339 |
+
*
|
340 |
+
* @version 2.4.0
|
341 |
+
*/
|
342 |
+
public function init( $id_count ) {
|
343 |
+
$this->id = ( 1 === $id_count ) ? 'jetpack_custom_gateway' : 'jetpack_custom_gateway_' . $id_count;
|
344 |
+
$this->has_fields = false;
|
345 |
+
$this->method_title = __( 'Custom Gateway', 'woocommerce-jetpack' ) . ' #' . $id_count;
|
346 |
+
$this->method_description = __( 'Booster for WooCommerce: Custom Payment Gateway', 'woocommerce-jetpack' ) . ' #' . $id_count;
|
347 |
+
$this->id_count = $id_count;
|
348 |
+
// Load the settings.
|
349 |
+
$this->init_form_fields();
|
350 |
+
$this->init_settings();
|
351 |
+
// Define user set variables
|
352 |
+
$this->title = $this->get_option( 'title' );
|
353 |
+
$this->description = $this->get_option( 'description' );
|
354 |
+
$this->instructions = $this->get_option( 'instructions', '' );//$this->description );
|
355 |
+
$this->instructions_in_email = $this->get_option( 'instructions_in_email', '' );
|
356 |
+
$this->icon = $this->get_option( 'icon', '' );//apply_filters( 'woocommerce_wcj_custom_icon', $this->get_option( 'icon', '' ) );
|
357 |
+
$this->min_amount = $this->get_option( 'min_amount', 0 );
|
358 |
+
$this->enable_for_methods = $this->get_option( 'enable_for_methods', array() );
|
359 |
+
$this->enable_for_virtual = $this->get_option( 'enable_for_virtual', 'yes' ) === 'yes' ? true : false;
|
360 |
+
$this->default_order_status = $this->get_option( 'default_order_status', 'pending' );
|
361 |
+
$this->send_email_to_admin = $this->get_option( 'send_email_to_admin', 'no' );
|
362 |
+
$this->send_email_to_customer = $this->get_option( 'send_email_to_customer', 'no' );
|
363 |
+
$this->custom_return_url = $this->get_option( 'custom_return_url', '' );
|
364 |
+
// Actions
|
365 |
+
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
366 |
+
add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) );
|
367 |
+
add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); // Customer Emails
|
368 |
+
}
|
369 |
|
370 |
+
/**
|
371 |
+
* Constructor.
|
372 |
+
*/
|
373 |
+
public function __construct() {
|
374 |
+
}
|
375 |
+
}
|
376 |
|
377 |
+
class WC_Gateway_WCJ_Custom extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( 1 ); } } // required
|
378 |
+
class WC_Gateway_WCJ_Custom_2 extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( 2 ); } }
|
379 |
+
class WC_Gateway_WCJ_Custom_3 extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( 3 ); } }
|
380 |
+
class WC_Gateway_WCJ_Custom_4 extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( 4 ); } }
|
381 |
+
class WC_Gateway_WCJ_Custom_5 extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( 5 ); } }
|
382 |
+
class WC_Gateway_WCJ_Custom_6 extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( 6 ); } }
|
383 |
+
class WC_Gateway_WCJ_Custom_7 extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( 7 ); } }
|
384 |
+
class WC_Gateway_WCJ_Custom_8 extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( 8 ); } }
|
385 |
+
class WC_Gateway_WCJ_Custom_9 extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( 9 ); } }
|
386 |
+
class WC_Gateway_WCJ_Custom_10 extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( 10 ); } }
|
387 |
+
function add_wc_gateway_wcj_custom_classes( $methods ) {
|
388 |
+
$methods[] = 'WC_Gateway_WCJ_Custom'; // required
|
389 |
+
$the_number = apply_filters( 'wcj_get_option_filter', 0, get_option( 'wcj_custom_payment_gateways_number' ) );
|
390 |
+
if ( $the_number > 10 ) $the_number = 10;
|
391 |
+
for ( $i = 2; $i <= $the_number; $i++ )
|
392 |
+
$methods[] = 'WC_Gateway_WCJ_Custom_' . $i;
|
393 |
+
return $methods;
|
394 |
+
}
|
395 |
+
add_filter( 'woocommerce_payment_gateways', 'add_wc_gateway_wcj_custom_classes' );
|
396 |
|
397 |
+
/* function add_wc_gateway_wcj_custom_classes( $methods ) {
|
398 |
+
for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 0, get_option( 'wcj_custom_payment_gateways_number' ) ); $i++ ) {
|
399 |
+
$class_name = ( 1 === $i ) ? 'WC_Gateway_WCJ_Custom' : 'WC_Gateway_WCJ_Custom_' . $i;
|
400 |
+
eval( 'class ' . $class_name . ' extends WC_Gateway_WCJ_Custom_Template { public function __construct() { $this->init( ' . $i . ' ); } }' );
|
401 |
+
$methods[] = $class_name;
|
402 |
+
}
|
403 |
+
return $methods;
|
404 |
+
}
|
405 |
+
add_filter( 'woocommerce_payment_gateways', 'add_wc_gateway_wcj_custom_classes' ); */
|
406 |
}
|
|
|
407 |
}
|
408 |
+
}
|
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: algoritmika,anbinder,solovjov
|
|
3 |
Tags: woocommerce,booster for woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,email pdf invoice,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price,custom css,hide categories count,hide subcategories count,hide category count,hide subcategory count,display total sales,custom product tabs,remove product tab,payment gateway fee,vat
|
4 |
Requires at least: 3.8
|
5 |
Tested up to: 4.4
|
6 |
-
Stable tag: 2.4.
|
7 |
License: GNU General Public License v3.0
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -118,6 +118,12 @@ To unlock all Booster for WooCommerce features, please install additional [Boost
|
|
118 |
|
119 |
== Changelog ==
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
= 2.4.1 - 04/03/2016 =
|
122 |
* Fix - PRICES & CURRENCIES - Wholesale Price - Discount info on cart page bug fixed.
|
123 |
* Fix - PRICES & CURRENCIES - Price by Country - Wrong currency in emails bug fixed.
|
3 |
Tags: woocommerce,booster for woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,email pdf invoice,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price,custom css,hide categories count,hide subcategories count,hide category count,hide subcategory count,display total sales,custom product tabs,remove product tab,payment gateway fee,vat
|
4 |
Requires at least: 3.8
|
5 |
Tested up to: 4.4
|
6 |
+
Stable tag: 2.4.2
|
7 |
License: GNU General Public License v3.0
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
118 |
|
119 |
== Changelog ==
|
120 |
|
121 |
+
= 2.4.2 - 04/03/2016 =
|
122 |
+
* Dev - CART & CHECKOUT - Mini Cart - Code refactoring.
|
123 |
+
* Dev - PAYMENT GATEWAYS - Gateways Currency - Code refactoring.
|
124 |
+
* Dev - PRICES & CURRENCIES - Currencies - Custom Currencies - Currency Symbol now can be empty.
|
125 |
+
* Fix - PAYMENT GATEWAYS - Custom Gateways - Additional checks in `init_wc_gateway_wcj_custom_class()`.
|
126 |
+
|
127 |
= 2.4.1 - 04/03/2016 =
|
128 |
* Fix - PRICES & CURRENCIES - Wholesale Price - Discount info on cart page bug fixed.
|
129 |
* Fix - PRICES & CURRENCIES - Price by Country - Wrong currency in emails bug fixed.
|
woocommerce-jetpack.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Booster for WooCommerce
|
4 |
Plugin URI: http://booster.io
|
5 |
Description: Supercharge your WooCommerce site with these awesome powerful features.
|
6 |
-
Version: 2.4.
|
7 |
Author: Algoritmika Ltd
|
8 |
Author URI: http://www.algoritmika.com
|
9 |
Copyright: © 2016 Algoritmika Ltd.
|
@@ -21,7 +21,7 @@ if ( ! class_exists( 'WC_Jetpack' ) ) :
|
|
21 |
* Main WC_Jetpack Class
|
22 |
*
|
23 |
* @class WC_Jetpack
|
24 |
-
* @version 2.4.
|
25 |
*/
|
26 |
|
27 |
final class WC_Jetpack {
|
@@ -385,14 +385,12 @@ final class WC_Jetpack {
|
|
385 |
/**
|
386 |
* Include modules and submodules
|
387 |
*
|
388 |
-
* @version 2.4.
|
389 |
*/
|
390 |
private function include_modules() {
|
391 |
$settings = array();
|
392 |
-
|
393 |
$settings[] = include_once( 'includes/class-wcj-price-labels.php' );
|
394 |
$settings[] = include_once( 'includes/class-wcj-call-for-price.php' );
|
395 |
-
|
396 |
$settings[] = include_once( 'includes/class-wcj-product-listings.php' );
|
397 |
$settings[] = include_once( 'includes/class-wcj-sorting.php' );
|
398 |
$settings[] = include_once( 'includes/class-wcj-product-custom-info.php' );
|
@@ -407,10 +405,8 @@ final class WC_Jetpack {
|
|
407 |
$settings[] = include_once( 'includes/class-wcj-crowdfunding.php' );
|
408 |
$settings[] = include_once( 'includes/class-wcj-wholesale-price.php' );
|
409 |
$settings[] = include_once( 'includes/class-wcj-product-images.php' );
|
410 |
-
|
411 |
$settings[] = include_once( 'includes/class-wcj-add-to-cart.php' );
|
412 |
$settings[] = include_once( 'includes/class-wcj-more-button-labels.php' );
|
413 |
-
|
414 |
$settings[] = include_once( 'includes/class-wcj-cart.php' );
|
415 |
$settings[] = include_once( 'includes/class-wcj-empty-cart-button.php' );
|
416 |
$settings[] = include_once( 'includes/class-wcj-mini-cart.php' );
|
@@ -424,36 +420,19 @@ final class WC_Jetpack {
|
|
424 |
$settings[] = include_once( 'includes/class-wcj-payment-gateways-currency.php' );
|
425 |
$settings[] = include_once( 'includes/class-wcj-payment-gateways-min-max.php' );
|
426 |
$settings[] = include_once( 'includes/class-wcj-payment-gateways-by-country.php' );
|
427 |
-
|
428 |
$settings[] = include_once( 'includes/class-wcj-shipping.php' );
|
429 |
$settings[] = include_once( 'includes/class-wcj-shipping-calculator.php' );
|
430 |
-
|
431 |
$settings[] = include_once( 'includes/class-wcj-address-formats.php' );
|
432 |
-
|
433 |
$settings[] = include_once( 'includes/class-wcj-orders.php' );
|
434 |
$settings[] = include_once( 'includes/class-wcj-order-numbers.php' );
|
435 |
$settings[] = include_once( 'includes/class-wcj-order-custom-statuses.php' );
|
436 |
-
|
437 |
// $settings[] = include_once( 'includes/class-wcj-pdf-invoices.php' );
|
438 |
-
|
439 |
$settings[] = include_once( 'includes/class-wcj-pdf-invoicing.php' );
|
440 |
-
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-numbering.php' );
|
441 |
-
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-templates.php' );
|
442 |
-
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-styling.php' );
|
443 |
-
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-header.php' );
|
444 |
-
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-footer.php' );
|
445 |
-
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-page.php' );
|
446 |
-
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-emails.php' );
|
447 |
-
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-display.php' );
|
448 |
-
// $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-general.php' );
|
449 |
-
|
450 |
$settings[] = include_once( 'includes/class-wcj-emails.php' );
|
451 |
-
|
452 |
$settings[] = include_once( 'includes/class-wcj-currencies.php' );
|
453 |
$settings[] = include_once( 'includes/class-wcj-currency-external-products.php' );
|
454 |
$settings[] = include_once( 'includes/class-wcj-price-by-country.php' );
|
455 |
$settings[] = include_once( 'includes/class-wcj-currency-exchange-rates.php' );
|
456 |
-
|
457 |
$settings[] = include_once( 'includes/class-wcj-general.php' );
|
458 |
// $settings[] = include_once( 'includes/class-wcj-shortcodes-module.php' );
|
459 |
$settings[] = include_once( 'includes/class-wcj-eu-vat-number.php' );
|
@@ -461,6 +440,15 @@ final class WC_Jetpack {
|
|
461 |
$settings[] = include_once( 'includes/class-wcj-reports.php' );
|
462 |
$settings[] = include_once( 'includes/class-wcj-admin-tools.php' );
|
463 |
$settings[] = include_once( 'includes/class-wcj-wpml.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
|
465 |
// do_action( 'woojetpack_modules', $settings );
|
466 |
|
3 |
Plugin Name: Booster for WooCommerce
|
4 |
Plugin URI: http://booster.io
|
5 |
Description: Supercharge your WooCommerce site with these awesome powerful features.
|
6 |
+
Version: 2.4.2
|
7 |
Author: Algoritmika Ltd
|
8 |
Author URI: http://www.algoritmika.com
|
9 |
Copyright: © 2016 Algoritmika Ltd.
|
21 |
* Main WC_Jetpack Class
|
22 |
*
|
23 |
* @class WC_Jetpack
|
24 |
+
* @version 2.4.2
|
25 |
*/
|
26 |
|
27 |
final class WC_Jetpack {
|
385 |
/**
|
386 |
* Include modules and submodules
|
387 |
*
|
388 |
+
* @version 2.4.2
|
389 |
*/
|
390 |
private function include_modules() {
|
391 |
$settings = array();
|
|
|
392 |
$settings[] = include_once( 'includes/class-wcj-price-labels.php' );
|
393 |
$settings[] = include_once( 'includes/class-wcj-call-for-price.php' );
|
|
|
394 |
$settings[] = include_once( 'includes/class-wcj-product-listings.php' );
|
395 |
$settings[] = include_once( 'includes/class-wcj-sorting.php' );
|
396 |
$settings[] = include_once( 'includes/class-wcj-product-custom-info.php' );
|
405 |
$settings[] = include_once( 'includes/class-wcj-crowdfunding.php' );
|
406 |
$settings[] = include_once( 'includes/class-wcj-wholesale-price.php' );
|
407 |
$settings[] = include_once( 'includes/class-wcj-product-images.php' );
|
|
|
408 |
$settings[] = include_once( 'includes/class-wcj-add-to-cart.php' );
|
409 |
$settings[] = include_once( 'includes/class-wcj-more-button-labels.php' );
|
|
|
410 |
$settings[] = include_once( 'includes/class-wcj-cart.php' );
|
411 |
$settings[] = include_once( 'includes/class-wcj-empty-cart-button.php' );
|
412 |
$settings[] = include_once( 'includes/class-wcj-mini-cart.php' );
|
420 |
$settings[] = include_once( 'includes/class-wcj-payment-gateways-currency.php' );
|
421 |
$settings[] = include_once( 'includes/class-wcj-payment-gateways-min-max.php' );
|
422 |
$settings[] = include_once( 'includes/class-wcj-payment-gateways-by-country.php' );
|
|
|
423 |
$settings[] = include_once( 'includes/class-wcj-shipping.php' );
|
424 |
$settings[] = include_once( 'includes/class-wcj-shipping-calculator.php' );
|
|
|
425 |
$settings[] = include_once( 'includes/class-wcj-address-formats.php' );
|
|
|
426 |
$settings[] = include_once( 'includes/class-wcj-orders.php' );
|
427 |
$settings[] = include_once( 'includes/class-wcj-order-numbers.php' );
|
428 |
$settings[] = include_once( 'includes/class-wcj-order-custom-statuses.php' );
|
|
|
429 |
// $settings[] = include_once( 'includes/class-wcj-pdf-invoices.php' );
|
|
|
430 |
$settings[] = include_once( 'includes/class-wcj-pdf-invoicing.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
$settings[] = include_once( 'includes/class-wcj-emails.php' );
|
|
|
432 |
$settings[] = include_once( 'includes/class-wcj-currencies.php' );
|
433 |
$settings[] = include_once( 'includes/class-wcj-currency-external-products.php' );
|
434 |
$settings[] = include_once( 'includes/class-wcj-price-by-country.php' );
|
435 |
$settings[] = include_once( 'includes/class-wcj-currency-exchange-rates.php' );
|
|
|
436 |
$settings[] = include_once( 'includes/class-wcj-general.php' );
|
437 |
// $settings[] = include_once( 'includes/class-wcj-shortcodes-module.php' );
|
438 |
$settings[] = include_once( 'includes/class-wcj-eu-vat-number.php' );
|
440 |
$settings[] = include_once( 'includes/class-wcj-reports.php' );
|
441 |
$settings[] = include_once( 'includes/class-wcj-admin-tools.php' );
|
442 |
$settings[] = include_once( 'includes/class-wcj-wpml.php' );
|
443 |
+
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-numbering.php' );
|
444 |
+
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-templates.php' );
|
445 |
+
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-styling.php' );
|
446 |
+
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-header.php' );
|
447 |
+
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-footer.php' );
|
448 |
+
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-page.php' );
|
449 |
+
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-emails.php' );
|
450 |
+
$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-display.php' );
|
451 |
+
// $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-general.php' );
|
452 |
|
453 |
// do_action( 'woojetpack_modules', $settings );
|
454 |
|