DeprecateOldTemplateHook.php
4 years ago
HookCommandInterface.php
5 years ago
SetupFieldConfirmation.php
4 years ago
SetupFieldEmailTag.php
4 years ago
SetupFieldPersistance.php
4 years ago
SetupFieldReceipt.php
4 years ago
SetupFieldValidation.php
4 years ago
SetupNewTemplateHook.php
4 years ago
SetupFieldConfirmation.php
79 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Form\LegacyConsumer\Commands; |
| 4 | |
| 5 | use Give\Framework\FieldsAPI\Field; |
| 6 | use Give\Framework\FieldsAPI\Group; |
| 7 | |
| 8 | /** |
| 9 | * @since 2.10.2 |
| 10 | */ |
| 11 | class SetupFieldConfirmation { |
| 12 | |
| 13 | /** |
| 14 | * @since 2.10.2 |
| 15 | * |
| 16 | * @param Donation $payment |
| 17 | * @param array $receiptArgs |
| 18 | */ |
| 19 | public function __construct( $payment, $receiptArgs ) { |
| 20 | $this->payment = $payment; |
| 21 | $this->receiptArgs = $receiptArgs; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * @since 2.10.2 |
| 26 | * |
| 27 | * @param string $hook |
| 28 | * |
| 29 | * @return void |
| 30 | */ |
| 31 | public function __invoke( $hook ) { |
| 32 | |
| 33 | $formID = give_get_payment_meta( $this->payment->ID, '_give_payment_form_id' ); |
| 34 | |
| 35 | $collection = Group::make( $hook ); |
| 36 | do_action( "give_fields_{$hook}", $collection, $formID ); |
| 37 | |
| 38 | $collection->walkFields( [ $this, 'render' ] ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @since 2.10.2 |
| 43 | * |
| 44 | * @param Field $field |
| 45 | * |
| 46 | * @return void |
| 47 | */ |
| 48 | public function render( Field $field ) { |
| 49 | |
| 50 | if ( ! $field->shouldShowInReceipt() ) { |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | if ( $field->shouldStoreAsDonorMeta() ) { |
| 55 | $donorID = give_get_payment_meta( $this->payment->ID, '_give_payment_donor_id' ); |
| 56 | $value = Give()->donor_meta->get_meta( $donorID, $field->getName(), true ); |
| 57 | } else { |
| 58 | $value = give_get_payment_meta( $this->payment->ID, $field->getName() ); |
| 59 | } |
| 60 | |
| 61 | if ( ! $value ) { |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | ?> |
| 66 | <tr> |
| 67 | <td scope="row"> |
| 68 | <strong> |
| 69 | <?php echo $field->getLabel(); ?> |
| 70 | </strong> |
| 71 | </td> |
| 72 | <td> |
| 73 | <?php echo $value; ?> |
| 74 | </td> |
| 75 | </tr> |
| 76 | <?php |
| 77 | } |
| 78 | } |
| 79 |