donation-amount-heading.php
4 years ago
header.php
2 years ago
icon-defs.php
4 years ago
loading.php
4 years ago
receipt.php
3 years ago
receipt.php
156 lines
| 1 | <?php |
| 2 | |
| 3 | use Give\Helpers\Form\Template; |
| 4 | use Give\Receipt\DonationReceipt; |
| 5 | use Give\Receipt\LineItem; |
| 6 | use Give\Receipt\Section; |
| 7 | use Give\Session\SessionDonation\DonationAccessor; |
| 8 | use Give\Views\IframeContentView; |
| 9 | use Give_Payment as Payment; |
| 10 | |
| 11 | $donationId = (new DonationAccessor())->getDonationId(); |
| 12 | $template = Give()->templates->getTemplate(); |
| 13 | $receipt = $template->getReceiptDetails($donationId); |
| 14 | $donation = new Payment($donationId); |
| 15 | $option = static function ($name) { |
| 16 | static $options = []; |
| 17 | |
| 18 | if (empty($options)) { |
| 19 | $options = Template::getOptions()['donation_receipt']; |
| 20 | } |
| 21 | |
| 22 | if (isset($options[$name])) { |
| 23 | return $options[$name]; |
| 24 | } |
| 25 | |
| 26 | return ''; |
| 27 | }; |
| 28 | |
| 29 | $hasDonationFailed = static function () use ($donation) { |
| 30 | return $donation->post_status === 'failed'; |
| 31 | }; |
| 32 | |
| 33 | $donorDashboardUrl = get_permalink(give_get_option('donor_dashboard_page')); |
| 34 | |
| 35 | $data = $hasDonationFailed() |
| 36 | ? [ |
| 37 | 'badgeIcon' => '#give-icon-cross', |
| 38 | 'badgeText' => esc_html__('Failed', 'give'), |
| 39 | 'title' => esc_html__('Donation Failed', 'give'), |
| 40 | 'description' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
| 41 | ] |
| 42 | : [ |
| 43 | 'badgeIcon' => '#give-icon-checkmark', |
| 44 | 'badgeText' => esc_html__('Success', 'give'), |
| 45 | 'title' => $receipt->heading, |
| 46 | 'description' => $receipt->message, |
| 47 | ]; |
| 48 | |
| 49 | ob_start(); |
| 50 | ?> |
| 51 | <?php include __DIR__ . '/icon-defs.php'; ?> |
| 52 | <article class="give-receipt-classic"> |
| 53 | <div class="give-form-header"> |
| 54 | <div class="give-form-header-top-wrap"> |
| 55 | <aside class="give-form-secure-badge"> |
| 56 | <svg class="give-form-secure-icon"> |
| 57 | <use href="<?= $data['badgeIcon'] ?>"/> |
| 58 | </svg> |
| 59 | <?= $data['badgeText'] ?>! |
| 60 | </aside> |
| 61 | <h1 class="give-receipt-title"> |
| 62 | <?= $data['title'] ?> |
| 63 | </h1> |
| 64 | <p class="give-form-description"> |
| 65 | <?= $data['description'] ?> |
| 66 | </p> |
| 67 | </div> |
| 68 | </div> |
| 69 | |
| 70 | <?php if ('enabled' === $option('social_sharing') && ! $hasDonationFailed()) : ?> |
| 71 | <div class="social-sharing"> |
| 72 | <p class="instruction"> |
| 73 | <?= esc_html__($option('sharing_instructions'),'give' ); ?> |
| 74 | </p> |
| 75 | <div class="btn-row"> |
| 76 | <button class="give-btn social-btn facebook-btn" onclick="GiveClassicTemplate.share(this);"> |
| 77 | <?= esc_html__('Share on Facebook', 'give'); ?> |
| 78 | <i class="fab fa-facebook"></i> |
| 79 | </button> |
| 80 | <button class="give-btn social-btn twitter-btn" onclick="GiveClassicTemplate.share(this);"> |
| 81 | <?= esc_html__('Share on Twitter', 'give'); ?> |
| 82 | <i class="fab fa-twitter"></i> |
| 83 | </button> |
| 84 | </div> |
| 85 | </div> |
| 86 | <?php endif; ?> |
| 87 | |
| 88 | <div class="receipt-sections"> |
| 89 | |
| 90 | <?php |
| 91 | foreach ($receipt as $section) : |
| 92 | /* @var Section $section */ |
| 93 | if (!$section->getLineItems() || 'PDFReceipt' === $section->id) { |
| 94 | continue; |
| 95 | } |
| 96 | ?> |
| 97 | |
| 98 | <div class="details"> |
| 99 | <?php if ($section->label) : ?> |
| 100 | <h2 class="headline"> |
| 101 | <?= $section->label; ?> |
| 102 | </h2> |
| 103 | <?php endif; ?> |
| 104 | <dl class="details-table"> |
| 105 | |
| 106 | <?php |
| 107 | foreach ($section as $lineItem) : |
| 108 | /* @var LineItem $lineItem */ |
| 109 | if (!$lineItem->value) { |
| 110 | continue; |
| 111 | } |
| 112 | |
| 113 | $class = ''; |
| 114 | if (DonationReceipt::DONATIONSECTIONID === $section->id) { |
| 115 | $class = 'totalAmount' === $lineItem->id ? 'total' : ''; |
| 116 | } |
| 117 | ?> |
| 118 | |
| 119 | <div class="details-row details-row--<?= $lineItem->id ?>"> |
| 120 | <?= $lineItem->icon ?> |
| 121 | <dt class="detail"><?= $lineItem->label ?></dt> |
| 122 | <dd class="value" |
| 123 | data-value="<?= esc_attr($lineItem->value) ?>"><?= $lineItem->value ?></dd> |
| 124 | </div> |
| 125 | <?php |
| 126 | endforeach; ?> |
| 127 | |
| 128 | </dl> |
| 129 | </div> |
| 130 | |
| 131 | <?php |
| 132 | endforeach; ?> |
| 133 | </div> |
| 134 | |
| 135 | <div class="dashboard-link-container"> |
| 136 | <a class="dashboard-link" href="<?= esc_url($donorDashboardUrl); ?>" target="_parent"> |
| 137 | <?= esc_html__('Go to my Donor Dashboard', 'give'); ?><i class="fas fa-long-arrow-alt-right"></i> |
| 138 | </a> |
| 139 | <?php |
| 140 | if (isset($section['receiptLink'])) : ?> |
| 141 | <div class="give-btn download-btn"> |
| 142 | <?= $section['receiptLink']->value; ?> |
| 143 | </div> |
| 144 | <?php |
| 145 | endif; ?> |
| 146 | </div> |
| 147 | </article> |
| 148 | |
| 149 | <?php |
| 150 | |
| 151 | $pageId = give_get_option('success_page'); |
| 152 | echo (new IframeContentView()) |
| 153 | ->setTitle(esc_html__('Donation Receipt', 'give'))->setPostId($pageId) |
| 154 | ->setBody(ob_get_clean()) |
| 155 | ->renderBody(); |
| 156 |