-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add option to disable one time donations for recurring enabl…
…ed forms (#6886) * feature: add recurringDisableOneTimeDonations option * fix: typo * refactor: only show option when donor choice is selected * fix: recurringDonationChoice should be donor by default * refactor: add one time to billing period options * Revert "refactor: add one time to billing period options" This reverts commit 56c3949. * refactor: rename to recurringEnableOneTimeDonations * refactor: update logic to determine when recurring details are fixed instead of donation choice * refactor: update recurring options logic and types * refactor: clean up converter with donation amount block model decorator * fix: default level * tests: update backwards compatiblity test --------- Co-authored-by: Jon Waldstein <[email protected]>
- Loading branch information
1 parent
48da0aa
commit 4bbd975
Showing
13 changed files
with
427 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
src/FormBuilder/BlockModels/DonationAmountBlockModel.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?php | ||
|
||
namespace Give\FormBuilder\BlockModels; | ||
|
||
use Give\Framework\Blocks\BlockModel; | ||
|
||
/** | ||
* This is a decorator for the Block Model block "givewp/donation-amount". | ||
* | ||
* @unreleased | ||
*/ | ||
class DonationAmountBlockModel { | ||
/** | ||
* @var BlockModel | ||
*/ | ||
public $block; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function __construct(BlockModel $block) { | ||
$this->block = $block; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getAttribute($name) | ||
{ | ||
return $this->block->getAttribute($name); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function hasAttribute($name): bool | ||
{ | ||
return $this->block->hasAttribute($name); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getLabel(): string | ||
{ | ||
return $this->block->getAttribute('label'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getLevels(): array | ||
{ | ||
return array_map('absint', $this->block->getAttribute('levels')); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* @return string|null | ||
*/ | ||
public function getDefaultLevel() | ||
{ | ||
return $this->block->getAttribute('defaultLevel'); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isRecurringFixed(): bool | ||
{ | ||
return count($this->block->getAttribute('recurringBillingPeriodOptions')) === 1 && $this->block->getAttribute('recurringEnableOneTimeDonations') === false; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getRecurringBillingInterval(): int | ||
{ | ||
return (int)$this->block->getAttribute('recurringBillingInterval'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getRecurringLengthOfTime(): int | ||
{ | ||
return (int)$this->block->getAttribute('recurringLengthOfTime'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getRecurringOptInDefaultBillingPeriod(): string | ||
{ | ||
return $this->block->getAttribute('recurringOptInDefaultBillingPeriod'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getRecurringBillingPeriodOptions(): array | ||
{ | ||
return $this->block->getAttribute('recurringBillingPeriodOptions'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function isRecurringEnableOneTimeDonations(): bool | ||
{ | ||
return $this->block->getAttribute('recurringEnableOneTimeDonations') === true; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function isRecurringEnabled(): bool | ||
{ | ||
return $this->block->getAttribute('recurringEnabled') === true; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function isCustomAmountEnabled(): bool | ||
{ | ||
return $this->block->getAttribute('customAmount') === true; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getPriceOption(): string | ||
{ | ||
return $this->block->getAttribute('priceOption'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getSetPrice(): int | ||
{ | ||
return $this->block->getAttribute('setPrice'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.