PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
← All changes | src/DonationForms/Actions/ConvertDonationAmountBlockToFieldsApi.php +10 -7 4.16.7 → 4.17.0 View file →
@@ -27,8 +27,10 @@
27 27 class ConvertDonationAmountBlockToFieldsApi
28 28 {
29 29
30 30 /**
31 + * @since 4.16.8 Exempt admin-defined amounts from the custom amount minimum and maximum, and fall back
32 + * to the lowest admin-defined amount when no custom amount minimum applies.
31 33 * @since 4.16.5 Set default value for the levelId hidden field.
32 34 * @since 4.10.0 Replaced generic 'currency' rule with custom CurrencyRule that uses GiveWP's currency list
33 35 * @since 3.0.0
34 36 *
@@ -38,8 +40,9 @@
38 40 public function __invoke(DonationAmountBlockModel $block, string $currency): DonationAmount
39 41 {
40 42 $amountField = DonationAmount::make('donationAmount')->tap(function (Group $group) use ($block, $currency) {
41 43 $amountRules = ['required', 'numeric'];
44 + $exemptAmounts = $block->getAdminDefinedAmounts();
42 45
43 46 if (!$block->isCustomAmountEnabled() &&
44 47 $block->getPriceOption() === 'set') {
45 48 $size = $block->getSetPrice();
@@ -44,18 +47,18 @@
44 47 $block->getPriceOption() === 'set') {
45 48 $size = $block->getSetPrice();
46 49
47 50 $amountRules[] = new Size($size);
48 - }
51 + } else {
52 + $minimum = $block->getMinimumAmount();
49 53
50 - if ($block->isCustomAmountEnabled()) {
51 - if ($block->hasAttribute('customAmountMin')) {
52 - $amountRules[] = new Min($block->getAttribute('customAmountMin'));
54 + if ($minimum !== null) {
55 + $amountRules[] = (new Min($minimum))->exemptAmounts(...$exemptAmounts);
53 56 }
57 + }
54 58
55 - if ($block->hasAttribute('customAmountMax') && $block->getAttribute('customAmountMax') > 0) {
56 - $amountRules[] = new Max($block->getAttribute('customAmountMax'));
57 - }
59 + if ($block->isCustomAmountEnabled() && $block->getCustomAmountMax() > 0) {
60 + $amountRules[] = (new Max($block->getCustomAmountMax()))->exemptAmounts(...$exemptAmounts);
58 61 }
59 62
60 63 /** @var Amount $amountNode */
61 64 $amountNode = $group->getNodeByName('amount');