Skip to content

Commit 1ee6666

Browse files
revert: suggested donation amounts without zeros
1 parent f26fef8 commit 1ee6666

File tree

2 files changed

+66
-63
lines changed

2 files changed

+66
-63
lines changed

includes/templates/wcdp_step_1_amount.php

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
* @var array $value
99
* @var string $form_id
1010
*/
11-
if (!defined('ABSPATH')) exit;
11+
if (!defined('ABSPATH'))
12+
exit;
1213

1314
$amount_layout = get_post_meta($product_id, 'wcdp-settings[0]', true);
1415

1516
//Donation Amount field
1617
$wcdp_price_decimals = apply_filters('wcdp_donation_amount_decimals', pow(10, wc_get_price_decimals() * (-1)));
17-
$max_range = (float)get_option('wcdp_max_range', 500);
18+
$max_range = (float) get_option('wcdp_max_range', 500);
1819
$value_donation_amount = "";
1920
$currency_symbol = get_woocommerce_currency_symbol();
2021

@@ -38,12 +39,12 @@
3839
}
3940

4041
?>
41-
<div id="wcdp_va_amount" class="wcdp_variation wcdp-row">
42-
<?php
43-
if ($amount_layout == 3) { //Expert design - action wcdp_custom_html_amount
44-
do_action('wcdp_custom_html_amount');
45-
do_action('wcdp_custom_html_amount_' . $value['id']);
46-
} else if ($amount_layout == 2) { //Input box with range slider ?>
42+
<div id="wcdp_va_amount" class="wcdp_variation wcdp-row">
43+
<?php
44+
if ($amount_layout == 3) { //Expert design - action wcdp_custom_html_amount
45+
do_action('wcdp_custom_html_amount');
46+
do_action('wcdp_custom_html_amount_' . $value['id']);
47+
} else if ($amount_layout == 2) { //Input box with range slider ?>
4748
<div class="wcdp-amount">
4849
<label for="wcdp-donation-amount">
4950
<?php
@@ -56,78 +57,78 @@
5657
<?php
5758
$wcdp_price_field = sprintf($wcdp_price_field, 'wcdp-amount-range-field');
5859
echo $wcdp_price_field
59-
?>
60-
<input id="<?php echo $form_id?>wcdp-range" name="wcdp-range" class="wcdp-range" aria-hidden="true" type="range"
61-
step="<?php echo (float)apply_filters('wcdp_range_slider_steps', 1); ?>"
62-
min="<?php echo $min_donation_amount ?>" max="<?php echo $max_range ?>">
60+
?>
61+
<input id="<?php echo $form_id ?>wcdp-range" name="wcdp-range" class="wcdp-range" aria-hidden="true"
62+
type="range" step="<?php echo (float) apply_filters('wcdp_range_slider_steps', 1); ?>"
63+
min="<?php echo $min_donation_amount ?>" max="<?php echo $max_range ?>">
6364
</div> <?php
64-
} else if ($amount_layout == 1) { //Radio/Button choices
65-
$suggestions = json_decode(get_post_meta($value['id'], 'wcdp-settings[1]', true));
66-
$price_format = get_woocommerce_price_format();
65+
} else if ($amount_layout == 1) { //Radio/Button choices
66+
$suggestions = json_decode(get_post_meta($value['id'], 'wcdp-settings[1]', true));
67+
$price_format = get_woocommerce_price_format();
6768

68-
$args = array(
69-
'ul-id' => 'wcdp_amount',
70-
'ul-class' => 'wcdp_options wcdp_amount',
71-
'name' => 'donation-amount',
72-
'options' => array()
73-
);
69+
$args = array(
70+
'ul-id' => 'wcdp_amount',
71+
'ul-class' => 'wcdp_options wcdp_amount',
72+
'name' => 'donation-amount',
73+
'options' => array()
74+
);
7475

75-
$option_already_checked = false;
76+
$option_already_checked = false;
7677

77-
if (!is_null($suggestions)) {
78-
foreach ($suggestions as $suggestion) {
79-
$suggestion = apply_filters('wcdp_suggestion', $suggestion, $product);
80-
if (is_numeric($suggestion) && $suggestion > 0 && $suggestion >= $min_donation_amount && $suggestion <= $max_donation_amount) {
81-
$option = array(
82-
'input-id' => 'amount_' . str_replace('.', '-', $suggestion),
83-
'input-value' => $suggestion,
84-
'input-class' => 'wcdp_amount_suggestion wcdp_amount_' . str_replace('.', '-', $suggestion),
85-
'label-text' => wc_price($suggestion),
86-
);
87-
if ($suggestion == $value_donation_amount) {
88-
$option['input-checked'] = true;
89-
$option_already_checked = true;
90-
}
91-
$args['options'][] = $option;
78+
if (!is_null($suggestions)) {
79+
foreach ($suggestions as $suggestion) {
80+
$suggestion = apply_filters('wcdp_suggestion', $suggestion, $product);
81+
if (is_numeric($suggestion) && $suggestion > 0 && $suggestion >= $min_donation_amount && $suggestion <= $max_donation_amount) {
82+
$option = array(
83+
'input-id' => 'amount_' . str_replace('.', '-', $suggestion),
84+
'input-value' => $suggestion,
85+
'input-class' => 'wcdp_amount_suggestion wcdp_amount_' . str_replace('.', '-', $suggestion),
86+
'label-text' => wc_price($suggestion, ['decimals' => 0]),
87+
);
88+
if ($suggestion == $value_donation_amount) {
89+
$option['input-checked'] = true;
90+
$option_already_checked = true;
9291
}
92+
$args['options'][] = $option;
9393
}
9494
}
95-
$wcdp_price_field = sprintf($wcdp_price_field, '');
96-
$option = array(
97-
'input-id' => 'wcdp_value_other',
98-
'input-value' => 'other',
99-
'input-class' => 'wcdp_value_other',
100-
'label-id' => 'label_custom_amount',
101-
'label-class' => 'wcdp_label_custom_amount',
102-
'label-text' => '<div id="wcdp_other" class="wcdp_other">' . apply_filters('wcdp_other_label', esc_html__('Other', 'wc-donation-platform')) . '</div><div class="wcdp_cu_field">' . $wcdp_price_field . '</div>',
103-
);
104-
if (!$option_already_checked && $value_donation_amount) {
105-
$option['input-checked'] = true;
106-
}
107-
$args['options'][] = $option; ?>
108-
<label class="wcdp-variation-heading" for="donation-amount">
95+
}
96+
$wcdp_price_field = sprintf($wcdp_price_field, '');
97+
$option = array(
98+
'input-id' => 'wcdp_value_other',
99+
'input-value' => 'other',
100+
'input-class' => 'wcdp_value_other',
101+
'label-id' => 'label_custom_amount',
102+
'label-class' => 'wcdp_label_custom_amount',
103+
'label-text' => '<div id="wcdp_other" class="wcdp_other">' . apply_filters('wcdp_other_label', esc_html__('Other', 'wc-donation-platform')) . '</div><div class="wcdp_cu_field">' . $wcdp_price_field . '</div>',
104+
);
105+
if (!$option_already_checked && $value_donation_amount) {
106+
$option['input-checked'] = true;
107+
}
108+
$args['options'][] = $option; ?>
109+
<label class="wcdp-variation-heading" for="donation-amount">
109110
<?php
110111
$title = get_option('wcdp_choose_amount_title', __('Choose an amount', 'wc-donation-platform'));
111112
echo esc_html($title);
112113
?>
113-
<abbr class="required" title="<?php esc_html_e('required', 'wc-donation-platform'); ?>">*</abbr>
114-
</label> <?php
115-
echo WCDP_Form::wcdp_generate_fieldset($args, null, $form_id);
116-
} else { //Default: just input box ?>
117-
<div class="wcdp-amount">
118-
<label for="wcdp-donation-amount">
114+
<abbr class="required" title="<?php esc_html_e('required', 'wc-donation-platform'); ?>">*</abbr>
115+
</label> <?php
116+
echo WCDP_Form::wcdp_generate_fieldset($args, null, $form_id);
117+
} else { //Default: just input box ?>
118+
<div class="wcdp-amount">
119+
<label for="wcdp-donation-amount">
119120
<?php
120121
$title = get_option('wcdp_contribution_title', __('Your Contribution', 'wc-donation-platform'));
121122
echo esc_html($title);
122123
?>
123-
<abbr class="required" title="<?php esc_html_e('required', 'wc-donation-platform'); ?>">*</abbr>
124-
</label>
125-
<br>
124+
<abbr class="required" title="<?php esc_html_e('required', 'wc-donation-platform'); ?>">*</abbr>
125+
</label>
126+
<br>
126127
<?php
127128
$wcdp_price_field = sprintf($wcdp_price_field, '');
128129
echo $wcdp_price_field;
129130
?>
130-
</div> <?php
131-
} ?>
132-
</div>
131+
</div> <?php
132+
} ?>
133+
</div>
133134
<?php

readme.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ If you want to disable the wording changes applied by Donation Platform for WooC
166166
Active development of Donation Platform for WooCommerce: Fundraising & Donation Management is handled [on GitHub](https://github.com/wc-donation/wc-donation-platform/).
167167

168168
= 1.3.5 =
169+
revert: suggested donation amounts without zeros
169170
dev: add wcdp_donate_label filter
170171
dev: add wcdp_other_label filter
172+
dev: add wcdp_product_settings_fundraising action
171173

172174
= 1.3.4.1 2025-05-24 =
173175
hotfix: fix anonymous donation checkbox always visible

0 commit comments

Comments
 (0)