-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathHelper.php
More file actions
87 lines (74 loc) · 1.73 KB
/
Copy pathHelper.php
File metadata and controls
87 lines (74 loc) · 1.73 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
81
82
83
84
85
86
87
<?php
/**
* Paytrail for WooCommerce payment Helper class
*/
namespace Paytrail\WooCommercePaymentGateway;
use Exception;
use LogicException;
class Helper {
/**
* Check is subscriptions enabled
*
* @return bool
*/
public static function getIsSubscriptionsEnabled() {
if (!class_exists('WC_Subscriptions_Cart')) {
return false;
}
if (!class_exists('WC_Subscriptions_Change_Payment_Gateway')) {
return false;
}
if (!function_exists('wcs_cart_contains_renewal')) {
return false;
}
if (class_exists('\WC_Subscriptions_Admin')) {
$accept_manual_renewals = ( 'no' !== get_option(\WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals', 'no') );
if (true == $accept_manual_renewals) {
return false;
}
}
return (
\WC_Subscriptions_Cart::cart_contains_subscription() ||
wcs_cart_contains_renewal() ||
filter_input(INPUT_GET, 'change_payment_method')
);
}
public static function getIsChangeSubscriptionPaymentMethod() {
return filter_input(INPUT_GET, 'change_payment_method');
}
/**
* Currency specific formatting
*
* @param int|double $sum The sum to format.
* @return integer
*/
public function handle_currency( $sum) {
return round($sum*100);
}
/**
* Get current WooCommerce cart total.
*
* @return integer
*/
public function get_cart_total() {
$sum = WC()->cart->total;
return $this->handle_currency($sum);
}
public static function getLocale() {
$full_locale = get_locale();
$short_locale = substr($full_locale, 0, 2);
// Get and assign the WordPress locale
switch ($short_locale) {
case 'sv':
$locale = 'SV';
break;
case 'fi':
$locale = 'FI';
break;
default:
$locale = 'EN';
break;
}
return $locale;
}
}