PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
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 2.30.0 All 255 releases
give / src / Form / LegacyConsumer / Commands / SetupFieldConfirmation.php

SetupFieldConfirmation.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Form/LegacyConsumer/Commands/SetupFieldConfirmation.php

97 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Form\LegacyConsumer\Commands;
4
5 use Give\Donations\Models\Donation;
6 use Give\Framework\FieldsAPI\Concerns\HasLabel;
7 use Give\Framework\FieldsAPI\Concerns\ShowInReceipt;
8 use Give\Framework\FieldsAPI\Field;
9 use Give\Framework\FieldsAPI\Group;
10
11 /**
12 * @since 2.10.2
13 */
14 class SetupFieldConfirmation
15 {
16 /**
17 * @var Donation
18 */
19 protected $payment;
20
21 /**
22 * @var array
23 */
24 protected $receiptArgs;
25
26 /**
27 * @since 2.10.2
28 *
29 * @param Donation $payment
30 * @param array $receiptArgs
31 */
32 public function __construct($payment, $receiptArgs)
33 {
34 $this->payment = $payment;
35 $this->receiptArgs = $receiptArgs;
36 }
37
38 /**
39 * @since 2.10.2
40 *
41 * @param string $hook
42 *
43 * @return void
44 */
45 public function __invoke($hook)
46 {
47 $formID = give_get_payment_meta($this->payment->ID, '_give_payment_form_id');
48
49 $collection = Group::make($hook);
50 do_action("give_fields_{$hook}", $collection, $formID);
51
52 $collection->walkFields([$this, 'render']);
53 }
54
55 /**
56 * @since 2.10.2
57 *
58 * @param Field $field
59 *
60 * @return void
61 */
62 public function render(Field $field)
63 {
64 /** @var Field|HasLabel $field */
65
66 if ( ! $field->shouldShowInReceipt()) {
67 return;
68 }
69
70 if ($field->shouldStoreAsDonorMeta()) {
71 $donorID = give_get_payment_meta($this->payment->ID, '_give_payment_donor_id');
72 $value = Give()->donor_meta->get_meta($donorID, $field->getName(), true);
73 } else {
74 $value = give_get_payment_meta($this->payment->ID, $field->getName());
75 }
76
77 if ( ! $value) {
78 return;
79 }
80
81 ?>
82 <tr>
83 <td scope="row">
84 <strong>
85 <?php
86 echo $field->getLabel(); ?>
87 </strong>
88 </td>
89 <td>
90 <?php
91 echo $value; ?>
92 </td>
93 </tr>
94 <?php
95 }
96 }
97