emails
8 years ago
global
8 years ago
receipt
7 years ago
single-give-form
8 years ago
email-login-form.php
8 years ago
history-donations.php
8 years ago
payment-processing.php
8 years ago
shortcode-donor-wall.php
7 years ago
shortcode-form-grid.php
8 years ago
shortcode-goal.php
7 years ago
shortcode-login.php
8 years ago
shortcode-profile-editor.php
8 years ago
shortcode-receipt.php
7 years ago
shortcode-register.php
8 years ago
shortcode-totals-progress.php
8 years ago
single-give-form.php
8 years ago
shortcode-receipt.php
323 lines
| 1 | <?php |
| 2 | /** |
| 3 | * This template is used to display the donation summary with [give_receipt] |
| 4 | */ |
| 5 | |
| 6 | global $give_receipt_args, $payment; |
| 7 | |
| 8 | // Validation: Ensure $payment var is set. |
| 9 | if ( empty( $payment ) ) { |
| 10 | $payment = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0; |
| 11 | } |
| 12 | |
| 13 | // Double-Validation: Check for $payment global. |
| 14 | if ( empty( $payment ) ) { |
| 15 | Give()->notices->print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) ); |
| 16 | |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | $donation_id = $payment->ID; |
| 21 | $donation_number = Give()->seq_donation_number->get_serial_code( $payment->ID ); |
| 22 | $form_id = give_get_payment_meta( $donation_id, '_give_payment_form_id', true ); |
| 23 | $donation = give_get_donation_form_title( $donation_id ); |
| 24 | $user = give_get_payment_meta_user_info( $donation_id ); |
| 25 | $email = give_get_payment_user_email( $donation_id ); |
| 26 | $status = $payment->post_status; |
| 27 | $status_label = give_get_payment_status( $payment, true ); |
| 28 | $company_name = give_get_payment_meta( $donation_id, '_give_donation_company', true ); |
| 29 | |
| 30 | // Update donor name, if title prefix is set. |
| 31 | $full_name = give_get_donor_name_with_title_prefixes( $user['title'], "{$user['first_name']} {$user['last_name']}" ); |
| 32 | |
| 33 | /** |
| 34 | * Generate Donation Receipt Arguments. |
| 35 | * |
| 36 | * Added donation receipt array to global variable $give_receipt_args to |
| 37 | * manage it from single variable |
| 38 | * |
| 39 | * @since 1.8.8 |
| 40 | */ |
| 41 | $give_receipt_args['donation_receipt']['donor'] = array( |
| 42 | 'name' => __( 'Donor', 'give' ), |
| 43 | 'value' => $full_name, |
| 44 | 'display' => $give_receipt_args['donor'], |
| 45 | ); |
| 46 | |
| 47 | /** |
| 48 | * Show Company name on Donation receipt Page |
| 49 | * |
| 50 | * @since 2.0.7 |
| 51 | * |
| 52 | * @param bool show/hide company name in donation receipt page. |
| 53 | * |
| 54 | * @return bool show/hide company name in donation receipt page. |
| 55 | */ |
| 56 | $give_receipt_args['donation_receipt']['company_name'] = array( |
| 57 | 'name' => __( 'Company Name', 'give' ), |
| 58 | 'value' => esc_attr( $company_name ), |
| 59 | // Do not show company field if empty |
| 60 | 'display' => empty( $company_name ) ? false : $give_receipt_args['company_name'], |
| 61 | ); |
| 62 | |
| 63 | $give_receipt_args['donation_receipt']['date'] = array( |
| 64 | 'name' => __( 'Date', 'give' ), |
| 65 | 'value' => date_i18n( give_date_format(), strtotime( give_get_payment_completed_date( $donation_id ) ) ), |
| 66 | 'display' => $give_receipt_args['date'], |
| 67 | ); |
| 68 | |
| 69 | $give_receipt_args['donation_receipt']['total_donation'] = array( |
| 70 | 'name' => __( 'Total Donation', 'give' ), |
| 71 | 'value' => give_donation_amount( $donation_id, array( 'currency' => true, 'amount' => true, 'type' => 'receipt' ) ), |
| 72 | 'display' => $give_receipt_args['price'], |
| 73 | ); |
| 74 | |
| 75 | $give_receipt_args['donation_receipt']['donation'] = array( |
| 76 | 'name' => __( 'Donation', 'give' ), |
| 77 | 'value' => $donation, |
| 78 | 'display' => true, |
| 79 | ); |
| 80 | |
| 81 | $give_receipt_args['donation_receipt']['donation_status'] = array( |
| 82 | 'name' => __( 'Donation Status', 'give' ), |
| 83 | 'value' => esc_attr( $status_label ), |
| 84 | 'display' => $give_receipt_args['payment_status'], |
| 85 | ); |
| 86 | |
| 87 | $give_receipt_args['donation_receipt']['donation_id'] = array( |
| 88 | 'name' => __( 'Donation ID', 'give' ), |
| 89 | 'value' => $donation_number, |
| 90 | 'display' => $give_receipt_args['payment_id'], |
| 91 | ); |
| 92 | |
| 93 | $give_receipt_args['donation_receipt']['payment_key'] = array( |
| 94 | 'name' => __( 'Payment Key', 'give' ), |
| 95 | 'value' => get_post_meta( $donation_id, '_give_payment_purchase_key', true ), |
| 96 | 'display' => $give_receipt_args['payment_key'], |
| 97 | ); |
| 98 | |
| 99 | $give_receipt_args['donation_receipt']['payment_method'] = array( |
| 100 | 'name' => __( 'Payment Method', 'give' ), |
| 101 | 'value' => give_get_gateway_checkout_label( give_get_payment_gateway( $donation_id ) ), |
| 102 | 'display' => $give_receipt_args['payment_method'], |
| 103 | ); |
| 104 | |
| 105 | /** |
| 106 | * Extend Give Donation Receipt |
| 107 | * |
| 108 | * You can easily extend the donation receipt argument using the filter give_donation_receipt_args |
| 109 | * |
| 110 | * @params array $give_receipt_args['donation_receipt'] Array of arguments for Donation Receipt. |
| 111 | * @params int $donation_id Donation ID. |
| 112 | * @params int $form_id Donation Form ID. |
| 113 | * |
| 114 | * @since 1.8.8 |
| 115 | */ |
| 116 | $give_receipt_args['donation_receipt'] = apply_filters( 'give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id ); |
| 117 | |
| 118 | // When the donation were made through offline donation, We won't show receipt and payment status though. |
| 119 | if ( 'offline' === give_get_payment_gateway( $payment->ID ) && 'pending' === $status ) { |
| 120 | |
| 121 | /** |
| 122 | * Before the offline donation receipt content starts. |
| 123 | * |
| 124 | * @since 1.8.14 |
| 125 | * |
| 126 | * @param Give_Payment $payment Donation payment object. |
| 127 | * @param array $give_receipt_args Receipt Arguments. |
| 128 | */ |
| 129 | do_action( 'give_receipt_before_offline_payment', $payment, $give_receipt_args ); |
| 130 | ?> |
| 131 | <h2><?php echo apply_filters( 'give_receipt_offline_payment_heading', __( 'Your Donation is Almost Complete!', 'give' ) ); ?></h2> |
| 132 | <div id="give_donation_receipt" class="<?php echo esc_attr( apply_filters( 'give_receipt_offline_payment_classes', 'give_receipt_offline_payment' ) ); ?>"> |
| 133 | <?php |
| 134 | // Instruction for offline donation. |
| 135 | $offline_instruction = give_get_offline_payment_instruction( $form_id, true ); |
| 136 | |
| 137 | /** |
| 138 | * Instruction for the offline donation. |
| 139 | * |
| 140 | * @since 1.8.14 |
| 141 | * |
| 142 | * @param string $offline_instruction Offline instruction content. |
| 143 | * @param Give_Payment $payment Payment object. |
| 144 | * @param integer $form_id Donation form id. |
| 145 | */ |
| 146 | echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id ); |
| 147 | ?> |
| 148 | </div> |
| 149 | <?php |
| 150 | /** |
| 151 | * After the offline donation content ends. |
| 152 | * |
| 153 | * @since 1.8.14 |
| 154 | * |
| 155 | * @param Give_Payment $payment Donation payment object. |
| 156 | * @param array $give_receipt_args Receipt Arguments. |
| 157 | */ |
| 158 | do_action( 'give_receipt_after_offline_payment', $payment, $give_receipt_args ); |
| 159 | |
| 160 | return; |
| 161 | } |
| 162 | |
| 163 | // Show payment status notice based on shortcode attribute. |
| 164 | if ( filter_var( $give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN ) ) { |
| 165 | $notice_message = ''; |
| 166 | $notice_type = 'warning'; |
| 167 | |
| 168 | switch ( $status ) { |
| 169 | case 'publish': |
| 170 | $notice_message = __( 'Payment Complete: Thank you for your donation.', 'give' ); |
| 171 | $notice_type = 'success'; |
| 172 | break; |
| 173 | case 'pending': |
| 174 | $notice_message = __( 'Payment Pending: Your donation is currently processing.', 'give' ); |
| 175 | $notice_type = 'warning'; |
| 176 | break; |
| 177 | case 'refunded': |
| 178 | $notice_message = __( 'Payment Refunded: Your donation has been refunded.', 'give' ); |
| 179 | $notice_type = 'warning'; |
| 180 | break; |
| 181 | case 'preapproval': |
| 182 | $notice_message = __( 'Payment Preapproved: Thank you for your donation.', 'give' ); |
| 183 | $notice_type = 'warning'; |
| 184 | break; |
| 185 | case 'failed': |
| 186 | $notice_message = __( 'Payment Failed: Please contact the site owner for assistance.', 'give' ); |
| 187 | $notice_type = 'error'; |
| 188 | break; |
| 189 | case 'cancelled': |
| 190 | $notice_message = __( 'Payment Cancelled: Your donation has been cancelled.', 'give' ); |
| 191 | $notice_type = 'error'; |
| 192 | break; |
| 193 | case 'abandoned': |
| 194 | $notice_message = __( 'Payment Abandoned: This donation has not been completed.', 'give' ); |
| 195 | $notice_type = 'error'; |
| 196 | break; |
| 197 | case 'revoked': |
| 198 | $notice_message = __( 'Payment Revoked: Please contact the site owner for assistance.', 'give' ); |
| 199 | $notice_type = 'error'; |
| 200 | break; |
| 201 | } |
| 202 | |
| 203 | if ( ! empty( $notice_message ) ) { |
| 204 | /** |
| 205 | * Filters payment status notice for receipts. |
| 206 | * |
| 207 | * By default, a success, warning, or error notice appears on the receipt |
| 208 | * with payment status. This filter allows the HTML markup |
| 209 | * and messaging for that notice to be customized. |
| 210 | * |
| 211 | * @since 1.0 |
| 212 | * |
| 213 | * @param string $notice HTML markup for the default notice. |
| 214 | * @param int $id Post ID where the notice is displayed. |
| 215 | * @param string $status Payment status. |
| 216 | * @param int $donation_id Donation ID. |
| 217 | */ |
| 218 | echo apply_filters( 'give_receipt_status_notice', Give()->notices->print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $donation_id ); |
| 219 | } |
| 220 | }// End if(). |
| 221 | |
| 222 | /** |
| 223 | * Fires in the payment receipt shortcode, before the receipt main table. |
| 224 | * |
| 225 | * Allows you to add elements before the table. |
| 226 | * |
| 227 | * @since 1.0 |
| 228 | * |
| 229 | * @param object $payment The payment object. |
| 230 | * @param array $give_receipt_args Receipt_argument. |
| 231 | */ |
| 232 | do_action( 'give_payment_receipt_before_table', $payment, $give_receipt_args ); |
| 233 | ?> |
| 234 | |
| 235 | <table id="give_donation_receipt" class="give-table"> |
| 236 | <thead> |
| 237 | <?php |
| 238 | /** |
| 239 | * Fires in the payment receipt shortcode, before the receipt first header item. |
| 240 | * |
| 241 | * Allows you to add new <th> elements before the receipt first header item. |
| 242 | * |
| 243 | * @since 1.7 |
| 244 | * |
| 245 | * @param object $payment The payment object. |
| 246 | * @param array $give_receipt_args Receipt_argument. |
| 247 | */ |
| 248 | do_action( 'give_payment_receipt_header_before', $payment, $give_receipt_args ); |
| 249 | ?> |
| 250 | <tr> |
| 251 | <th scope="colgroup" colspan="2"> |
| 252 | <span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ) ?></span> |
| 253 | </th> |
| 254 | </tr> |
| 255 | <?php |
| 256 | /** |
| 257 | * Fires in the payment receipt shortcode, after the receipt last header item. |
| 258 | * |
| 259 | * Allows you to add new <th> elements after the receipt last header item. |
| 260 | * |
| 261 | * @since 1.7 |
| 262 | * |
| 263 | * @param object $payment The payment object. |
| 264 | * @param array $give_receipt_args Receipt_argument. |
| 265 | */ |
| 266 | do_action( 'give_payment_receipt_header_after', $payment, $give_receipt_args ); |
| 267 | ?> |
| 268 | </thead> |
| 269 | |
| 270 | <tbody> |
| 271 | <?php |
| 272 | /** |
| 273 | * Fires in the payment receipt shortcode, before the receipt first item. |
| 274 | * |
| 275 | * Allows you to add new <td> elements before the receipt first item. |
| 276 | * |
| 277 | * @since 1.7 |
| 278 | * |
| 279 | * @param object $payment The payment object. |
| 280 | * @param array $give_receipt_args Receipt_argument. |
| 281 | */ |
| 282 | do_action( 'give_payment_receipt_before', $payment, $give_receipt_args ); |
| 283 | ?> |
| 284 | |
| 285 | <?php foreach ( $give_receipt_args['donation_receipt'] as $receipt_item ) { ?> |
| 286 | <?php if ( filter_var( $receipt_item['display'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
| 287 | <tr> |
| 288 | <td scope="row"><strong><?php echo $receipt_item['name']; ?></strong></td> |
| 289 | <td><?php echo $receipt_item['value']; ?></td> |
| 290 | </tr> |
| 291 | <?php endif; ?> |
| 292 | <?php } ?> |
| 293 | |
| 294 | <?php |
| 295 | /** |
| 296 | * Fires in the payment receipt shortcode, after the receipt last item. |
| 297 | * |
| 298 | * Allows you to add new <td> elements after the receipt last item. |
| 299 | * |
| 300 | * @since 1.7 |
| 301 | * |
| 302 | * @param object $payment The payment object. |
| 303 | * @param array $give_receipt_args Receipt_argument. |
| 304 | */ |
| 305 | do_action( 'give_payment_receipt_after', $payment, $give_receipt_args ); |
| 306 | ?> |
| 307 | </tbody> |
| 308 | </table> |
| 309 | |
| 310 | <?php |
| 311 | /** |
| 312 | * Fires in the payment receipt shortcode, after the receipt main table. |
| 313 | * |
| 314 | * Allows you to add elements after the table. |
| 315 | * |
| 316 | * @since 1.7 |
| 317 | * |
| 318 | * @param object $payment The payment object. |
| 319 | * @param array $give_receipt_args Receipt_argument. |
| 320 | */ |
| 321 | do_action( 'give_payment_receipt_after_table', $payment, $give_receipt_args ); |
| 322 | ?> |
| 323 |