PluginProbe
PayPlug for WooCommerce (Official) / 3.1.0
PayPlug for WooCommerce (Official) v3.1.0
3.1.0 3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 All 102 releases
← All changes | src/Gateway/PayplugGatewayOney4xWithoutFees.php +13 -43 1.10.0 → 3.1.0 View file →
@@ -10,21 +10,19 @@
10 10 }
11 11
12 12 /**
13 13 * PayPlug WooCommerce Gateway.
14 - *
15 - * @package Payplug\PayplugWoocommerce\Gateway
16 14 */
17 15 class PayplugGatewayOney4xWithoutFees extends PayplugGatewayOney3x
18 16 {
19 -
20 17 public function __construct()
21 18 {
22 19 parent::__construct();
23 - $this->id = 'oney_x4_without_fees';
24 - $this->method_title = _x('PayPlug Oney 4x', 'Gateway method title', 'payplug');
20 + $this->id = 'oney_x4_without_fees';
21 + $this->method_title = _x('PayPlug Oney 4x', 'Gateway method title', 'payplug');
25 22 $this->method_description = __('Enable PayPlug Oney 4x for your customers.', 'payplug');
26 - $this->title = __('Pay by credit card in 4x installments without fees with Oney', 'payplug');
23 + $this->title = __('Pay by credit card in 4x installments without fees with Oney', 'payplug');
24 + $this->has_fields = true;
27 25 }
28 26
29 27 /**
30 28 * Get payment icons.
@@ -32,52 +30,24 @@
32 30 * @return string
33 31 */
34 32 public function get_icon()
35 33 {
36 - if ($this->check_oney_is_available() === true) {
37 - $total_price = floatval(WC()->cart->total);
38 - $this->oney_response = $this->api->simulate_oney_payment($total_price, 'without_fees');
39 - $currency = get_woocommerce_currency_symbol(get_option('woocommerce_currency'));
40 - $f = function ($fn) {
41 - return $fn;
42 - };
43 - if(is_array($this->oney_response)) {
44 - $this->description = <<<HTML
45 - <p>
46 - <div class="payplug-oney-flex">
47 - <div>{$f(__('Bring', 'payplug'))}:</div>
48 - <div>{$this->oney_response['x4_without_fees']['down_payment_amount']} {$currency}</div>
49 - </div>
50 - <div class="payplug-oney-flex">
51 - <div>{$f(__('1st monthly payment', 'payplug'))}:</div>
52 - <div>{$this->oney_response['x4_without_fees']['installments'][0]['amount']} {$currency}</div>
53 - </div>
54 - <div class="payplug-oney-flex">
55 - <div>{$f(__('2nd monthly payment', 'payplug'))}:</div>
56 - <div>{$this->oney_response['x4_without_fees']['installments'][1]['amount']} {$currency}</div>
57 - </div>
58 - <div class="payplug-oney-flex">
59 - <div>{$f(__('3rd monthly payment', 'payplug'))}:</div>
60 - <div>{$this->oney_response['x4_without_fees']['installments'][2]['amount']} {$currency}</div>
61 - </div>
62 - </p>
63 -HTML;
64 - } else {
65 - $this->description = $this->oney_response;
66 - }
34 + $disable = $this->check_oney_is_available() === true ? '' : 'disable-checkout-icons';
35 + $country = PayplugWoocommerceHelper::getISOCountryCode();
36 +
37 + if (file_exists(PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/checkout/x4_without_fees_' . $country . '.svg')) {
38 + $image = PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/checkout/x4_without_fees_' . $country . '.svg';
39 + } else {
40 + $image = PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/checkout/x4_without_fees_FR.svg';
67 41 }
68 42
69 - $country = PayplugWoocommerceHelper::getISOCountryCode();
70 - $available_img = file_exists(PAYPLUG_GATEWAY_PLUGIN_DIR . 'assets/images/Oney4x-' . $country . '.png') ? 'Oney4x-' . $country . '.png' : 'Oney4x.png';
71 - $disable_img = file_exists(PAYPLUG_GATEWAY_PLUGIN_DIR . 'assets/images/Oney4x_grey-' . $country . '.png') ? 'Oney4x_grey-' . $country . '.png' : 'Oney4x_grey.png';
72 - $image = ($this->check_oney_is_available() === true) ? $available_img : $disable_img;
73 -
74 43 $icons = apply_filters('payplug_payment_icons', [
75 - 'payplug' => sprintf('<img src="%s" alt="Oney 4x" class="payplug-payment-icon" />', esc_url(PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/' . $image)),
44 + 'payplug' => sprintf('<img src="%s" alt="Oney 4x" class="payplug-payment-icon ' . $disable . '" />', esc_url($image)),
76 45 ]);
77 46 $icons_str = '';
78 47 foreach ($icons as $icon) {
79 48 $icons_str .= $icon;
80 49 }
50 +
81 51 return $icons_str;
82 52 }
83 53 }