Server IP : 192.158.238.246 / Your IP : 3.148.108.24 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/cwd/plugins/give/src/DonationForms/Listeners/ |
Upload File : |
<?php namespace Give\DonationForms\Listeners; use Give\DonationForms\Models\DonationForm; use Give\Donations\Models\Donation; use Give\Framework\Exceptions\Primitives\Exception; use Give\Framework\FieldsAPI\Amount; use Give\Framework\FieldsAPI\Exceptions\NameCollisionException; class UpdateDonationLevelId { /** * if the intended donation amount matches a donation level from the amount block settings, * this will update the donation level ID meta with the level array key, * which is used in the donation details screen. * * @since 3.0.0 * * @throws NameCollisionException|Exception */ public function __invoke(DonationForm $donationForm, Donation $donation) { /** @var Amount $amountField */ $amountField = $donationForm->schema()->getNodeByName('amount'); if (!$amountField) { return; } $donationLevel = array_search( (float)$donation->intendedAmount()->formatToDecimal(), $amountField->getLevels(), true ); if ($donationLevel !== false) { $donation->levelId = (string)$donationLevel; $donation->save(); } } }