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