| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\TestData\Addons\ManualDonations; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
use Give\TestData\Framework\MetaRepository; |
| 7 |
|
| 8 |
/** |
| 9 |
* Class ManualDonations |
| 10 |
* @package Give\TestData\ManualDonations |
| 11 |
* |
| 12 |
* @since 2.15.0 update class code to maintain PHP 5.6 compatibility |
| 13 |
*/ |
| 14 |
class ManualDonations |
| 15 |
{ |
| 16 |
|
| 17 |
const GATEWAY = 'manual_donation'; |
| 18 |
|
| 19 |
/** |
| 20 |
* @param int $donationID |
| 21 |
* @param array $donation |
| 22 |
*/ |
| 23 |
public function updateDonationMeta($donationID, $donation) |
| 24 |
{ |
| 25 |
global $wpdb; |
| 26 |
|
| 27 |
// Check gateway |
| 28 |
if ($donation['payment_gateway'] !== self::GATEWAY) { |
| 29 |
return; |
| 30 |
} |
| 31 |
|
| 32 |
// Start DB transaction |
| 33 |
$wpdb->query('START TRANSACTION'); |
| 34 |
|
| 35 |
try { |
| 36 |
// Update donation meta |
| 37 |
$metaRepository = new MetaRepository('give_donationmeta', 'donation_id'); |
| 38 |
$metaRepository->persist($donationID, ['_give_manually_added_donation' => 1]); |
| 39 |
|
| 40 |
$wpdb->query('COMMIT'); |
| 41 |
} catch (Exception $e) { |
| 42 |
$wpdb->query('ROLLBACK'); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
} |
| 47 |
|