Skip to content

Commit a0be0bb

Browse files
committed
fix on shortcode for 3, 12 times payments
1 parent 5014437 commit a0be0bb

4 files changed

Lines changed: 61 additions & 10 deletions

File tree

block/helloasso-woocommerce-blocks.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,22 @@ public function get_payment_method_data()
4646
$multi_12_enabled = isset($this->settings['multi_12_enabled']) && $this->settings['multi_12_enabled'] === 'yes';
4747

4848
$payment_choices = ['one_time'];
49-
if ($multi_3_enabled) {
49+
50+
$current_day = (int) current_time('j');
51+
$can_show_multi_payment = $current_day <= 28;
52+
53+
if ($multi_3_enabled && $can_show_multi_payment) {
5054
$payment_choices[] = 'three_times';
5155
}
52-
if ($multi_12_enabled) {
56+
if ($multi_12_enabled && $can_show_multi_payment) {
5357
$payment_choices[] = 'twelve_times';
5458
}
5559

5660
return [
5761
'title' => $this->gateway->title,
5862
'description' => $this->gateway->description,
59-
'multi_3_enabled' => $multi_3_enabled,
60-
'multi_12_enabled' => $multi_12_enabled,
63+
'multi_3_enabled' => $multi_3_enabled && $can_show_multi_payment,
64+
'multi_12_enabled' => $multi_12_enabled && $can_show_multi_payment,
6165
'payment_choices' => $payment_choices
6266
];
6367
}

cron/helloasso-woocommerce-cron.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ function hello_asso_cron_refresh_token()
55
helloasso_refresh_token_asso();
66
}
77

8-
if (!wp_next_scheduled('hello_asso_cron_refresh_token__hook')) {
9-
wp_schedule_event(strtotime('00:00:00'), 'daily', 'hello_asso_cron_refresh_token__hook');
8+
if (!wp_next_scheduled('hello_asso_cron_refresh_token_hook')) {
9+
wp_schedule_event(strtotime('00:00:00'), 'daily', 'hello_asso_cron_refresh_token_hook');
1010
}
1111

1212
function helloasso_refresh_token_asso()
@@ -56,4 +56,4 @@ function helloasso_refresh_token_asso()
5656
}
5757
}
5858

59-
add_action('cron_refresh_token_hello_asso__hook', 'cron_refresh_token_hello_asso');
59+
add_action('hello_asso_cron_refresh_token_hook', 'hello_asso_cron_refresh_token');

helloasso-woocommerce-gateway.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Plugin Name: HelloAsso Payments for WooCommerce
55
* Description: Recevez 100% de vos paiements gratuitement. HelloAsso est la seule solution de paiement gratuite du secteur associatif. Nous sommes financés librement par la solidarité de celles et ceux qui choisissent de laisser une contribution volontaire au moment du paiement à une association.
6-
* Version: 1.0.9
6+
* Version: 1.0.10
77
* Requires at least: 5.0
88
* WC requires at least: 7.7
99
* Requires PHP: 7.2.34
@@ -142,6 +142,48 @@ public function __construct()
142142
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
143143
}
144144

145+
public function payment_fields()
146+
{
147+
if ($this->description) {
148+
echo '<div style="display: flex; align-items: center;">';
149+
echo '<img style="max-width: 50px; height:auto; margin-right: 16px;" src="/wp-content/plugins/helloasso-payments-for-woocommerce/assets/logo-ha.png" alt="HelloAsso Logo" />';
150+
echo '<p>' . wp_kses_post($this->description) . '</p>';
151+
echo '</div>';
152+
}
153+
154+
$multi_3_enabled = $this->get_option('multi_3_enabled') === 'yes';
155+
$multi_12_enabled = $this->get_option('multi_12_enabled') === 'yes';
156+
157+
$current_day = (int) current_time('j');
158+
$can_show_multi_payment = $current_day <= 28;
159+
160+
if (($multi_3_enabled || $multi_12_enabled) && $can_show_multi_payment) {
161+
echo '<div id="helloasso-payment-options">';
162+
echo '<p><strong>Choisissez votre mode de paiement:</strong></p>';
163+
164+
echo '<label style="display: block; margin-bottom: 8px;">';
165+
echo '<input type="radio" name="helloasso_payment_type" value="one_time" checked="checked" style="margin-right: 5px;" />';
166+
echo 'Paiement comptant';
167+
echo '</label>';
168+
169+
if ($multi_3_enabled) {
170+
echo '<label style="display: block; margin-bottom: 8px;">';
171+
echo '<input type="radio" name="helloasso_payment_type" value="three_times" style="margin-right: 5px;" />';
172+
echo 'Paiement en 3 fois sans frais';
173+
echo '</label>';
174+
}
175+
176+
if ($multi_12_enabled) {
177+
echo '<label style="display: block; margin-bottom: 8px;">';
178+
echo '<input type="radio" name="helloasso_payment_type" value="twelve_times" style="margin-right: 5px;" />';
179+
echo 'Paiement en 12 fois sans frais';
180+
echo '</label>';
181+
}
182+
183+
echo '</div>';
184+
}
185+
}
186+
145187
public function admin_options()
146188
{
147189
// Check if we have helloasso_access_token_asso in the options

readme.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Contributors: helloasso
33
Donate link: https://helloasso.com
44
Tags: helloasso, payment, association, don, billetterie
55
Requires at least: 5.0
6-
Tested up to: 6.8
6+
Tested up to: 6.8.1
77
Requires PHP: 7.2.34
8-
Stable tag: 1.0.9
8+
Stable tag: 1.0.10
99
License: GPLv3
1010
License URI: https://www.gnu.org/licenses/gpl-3.0.html
1111

@@ -96,6 +96,11 @@ Please report security bugs found in the source code of the helloasso plugin thr
9696

9797
== Changelog ==
9898

99+
= 1.0.10 =
100+
* Affichage du paiement en trois et douze fois même avec le shortcode
101+
* Le paiement en trois et douze fois n'est plus proposé si le jour est > supérieur à 28
102+
* Correction sur le cron
103+
99104
= 1.0.9 =
100105
* Ajout du paiement en trois et douze fois
101106

0 commit comments

Comments
 (0)