/pages/confirmation.php

https://github.com/strangerstudios/paid-memberships-pro · PHP · 154 lines · 117 code · 14 blank · 23 comment · 29 complexity · a885462f200674f4d8ef3b3b6859a2fa MD5 · raw file

  1. <?php
  2. /**
  3. * Template: Confirmation
  4. *
  5. * See documentation for how to override the PMPro templates.
  6. * @link https://www.paidmembershipspro.com/documentation/templates/
  7. *
  8. * @version 2.0
  9. *
  10. * @author Paid Memberships Pro
  11. */
  12. ?>
  13. <div class="<?php echo pmpro_get_element_class( 'pmpro_confirmation_wrap' ); ?>">
  14. <?php
  15. global $wpdb, $current_user, $pmpro_invoice, $pmpro_msg, $pmpro_msgt;
  16. if($pmpro_msg)
  17. {
  18. ?>
  19. <div class="<?php echo pmpro_get_element_class( 'pmpro_message ' . $pmpro_msgt, $pmpro_msgt ); ?>"><?php echo wp_kses_post( $pmpro_msg );?></div>
  20. <?php
  21. }
  22. if(empty($current_user->membership_level))
  23. $confirmation_message = "<p>" . __('Your payment has been submitted. Your membership will be activated shortly.', 'paid-memberships-pro' ) . "</p>";
  24. else
  25. $confirmation_message = "<p>" . sprintf(__('Thank you for your membership to %s. Your %s membership is now active.', 'paid-memberships-pro' ), get_bloginfo("name"), $current_user->membership_level->name) . "</p>";
  26. //confirmation message for this level
  27. $level_message = $wpdb->get_var("SELECT l.confirmation FROM $wpdb->pmpro_membership_levels l LEFT JOIN $wpdb->pmpro_memberships_users mu ON l.id = mu.membership_id WHERE mu.status = 'active' AND mu.user_id = '" . $current_user->ID . "' LIMIT 1");
  28. if(!empty($level_message))
  29. $confirmation_message .= "\n" . stripslashes($level_message) . "\n";
  30. ?>
  31. <?php if(!empty($pmpro_invoice) && !empty($pmpro_invoice->id)) { ?>
  32. <?php
  33. $pmpro_invoice->getUser();
  34. $pmpro_invoice->getMembershipLevel();
  35. $confirmation_message .= "<p>" . sprintf(__('Below are details about your membership account and a receipt for your initial membership invoice. A welcome email with a copy of your initial membership invoice has been sent to %s.', 'paid-memberships-pro' ), $pmpro_invoice->user->user_email) . "</p>";
  36. // Check instructions
  37. if ( $pmpro_invoice->gateway == "check" && ! pmpro_isLevelFree( $pmpro_invoice->membership_level ) ) {
  38. $confirmation_message .= '<div class="' . pmpro_get_element_class( 'pmpro_payment_instructions' ) . '">' . wpautop( wp_unslash( pmpro_getOption("instructions") ) ) . '</div>';
  39. }
  40. /**
  41. * All devs to filter the confirmation message.
  42. * We also have a function in includes/filters.php that applies the the_content filters to this message.
  43. * @param string $confirmation_message The confirmation message.
  44. * @param object $pmpro_invoice The PMPro Invoice/Order object.
  45. */
  46. $confirmation_message = apply_filters("pmpro_confirmation_message", $confirmation_message, $pmpro_invoice);
  47. echo wp_kses_post( $confirmation_message );
  48. ?>
  49. <h3>
  50. <?php printf(__('Invoice #%s on %s', 'paid-memberships-pro' ), $pmpro_invoice->code, date_i18n(get_option('date_format'), $pmpro_invoice->getTimestamp()));?>
  51. </h3>
  52. <a class="<?php echo pmpro_get_element_class( 'pmpro_a-print' ); ?>" href="javascript:window.print()"><?php esc_html_e('Print', 'paid-memberships-pro' );?></a>
  53. <ul>
  54. <?php do_action("pmpro_invoice_bullets_top", $pmpro_invoice); ?>
  55. <li><strong><?php esc_html_e('Account', 'paid-memberships-pro' );?>:</strong> <?php echo esc_html( $current_user->display_name );?> (<?php echo esc_html( $current_user->user_email );?>)</li>
  56. <li><strong><?php esc_html_e('Membership Level', 'paid-memberships-pro' );?>:</strong> <?php echo esc_html( $pmpro_invoice->membership_level->name);?> <?php if ( in_array( $pmpro_invoice->status, array( 'pending', 'token' ) ) ) { echo ' (' . esc_html__( 'Pending', 'paid-memberships-pro' ) . ')'; }?></li>
  57. <?php if( ! empty( $current_user->membership_level->enddate ) && ! in_array( $pmpro_invoice->status, array( 'pending', 'token' ) ) ) { ?>
  58. <li><strong><?php esc_html_e('Membership Expires', 'paid-memberships-pro' );?>:</strong> <?php echo date_i18n(get_option('date_format'), $current_user->membership_level->enddate)?></li>
  59. <?php } ?>
  60. <?php if($pmpro_invoice->getDiscountCode()) { ?>
  61. <li><strong><?php esc_html_e('Discount Code', 'paid-memberships-pro' );?>:</strong> <?php echo esc_html( $pmpro_invoice->discount_code->code );?></li>
  62. <?php } ?>
  63. <?php do_action("pmpro_invoice_bullets_bottom", $pmpro_invoice); ?>
  64. </ul>
  65. <hr />
  66. <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice_details' ); ?>">
  67. <?php if(!empty($pmpro_invoice->billing->street)) { ?>
  68. <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice-billing-address' ); ?>">
  69. <strong><?php esc_html_e('Billing Address', 'paid-memberships-pro' );?></strong>
  70. <p>
  71. <span class="<?php echo pmpro_get_element_class( 'pmpro_invoice-field-billing_name' ); ?>"><?php echo $pmpro_invoice->billing->name; ?></span>
  72. <span class="<?php echo pmpro_get_element_class( 'pmpro_invoice-field-billing_street' ); ?>"><?php echo $pmpro_invoice->billing->street; ?></span>
  73. <?php if ( $pmpro_invoice->billing->city && $pmpro_invoice->billing->state ) { ?>
  74. <span class="<?php echo pmpro_get_element_class( 'pmpro_invoice-field-billing_city' ); ?>"><?php echo $pmpro_invoice->billing->city; ?></span>
  75. <span class="<?php echo pmpro_get_element_class( 'pmpro_invoice-field-billing_state' ); ?>"><?php echo $pmpro_invoice->billing->state; ?></span>
  76. <span class="<?php echo pmpro_get_element_class( 'pmpro_invoice-field-billing_zip' ); ?>"><?php echo $pmpro_invoice->billing->zip; ?></span>
  77. <span class="<?php echo pmpro_get_element_class( 'pmpro_invoice-field-billing_country' ); ?>"><?php echo $pmpro_invoice->billing->country; ?></span>
  78. <?php } ?>
  79. <span class="<?php echo pmpro_get_element_class( 'pmpro_invoice-field-billing_phone' ); ?>"><?php echo formatPhone($pmpro_invoice->billing->phone); ?></span>
  80. </p>
  81. </div> <!-- end pmpro_invoice-billing-address -->
  82. <?php } ?>
  83. <?php if ( ! empty( $pmpro_invoice->accountnumber ) || ! empty( $pmpro_invoice->payment_type ) ) { ?>
  84. <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice-payment-method' ); ?>">
  85. <strong><?php esc_html_e('Payment Method', 'paid-memberships-pro' );?></strong>
  86. <?php if($pmpro_invoice->accountnumber) { ?>
  87. <p><?php echo esc_html( ucwords( $pmpro_invoice->cardtype ) ); ?> <?php _e('ending in', 'paid-memberships-pro' );?> <?php echo esc_html( last4($pmpro_invoice->accountnumber ) );?>
  88. <br />
  89. <?php _e('Expiration', 'paid-memberships-pro' );?>: <?php echo esc_html( $pmpro_invoice->expirationmonth );?>/<?php echo esc_html( $pmpro_invoice->expirationyear );?></p>
  90. <?php } else { ?>
  91. <p><?php echo esc_html( $pmpro_invoice->payment_type ); ?></p>
  92. <?php } ?>
  93. </div> <!-- end pmpro_invoice-payment-method -->
  94. <?php } ?>
  95. <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice-total' ); ?>">
  96. <strong><?php esc_html_e('Total Billed', 'paid-memberships-pro' );?></strong>
  97. <p>
  98. <?php
  99. if ( (float)$pmpro_invoice->total > 0 ) {
  100. echo pmpro_get_price_parts( $pmpro_invoice, 'span' );
  101. } else {
  102. echo pmpro_escape_price( pmpro_formatPrice(0) );
  103. }
  104. ?>
  105. </p>
  106. </div> <!-- end pmpro_invoice-total -->
  107. </div> <!-- end pmpro_invoice -->
  108. <hr />
  109. <?php
  110. }
  111. else
  112. {
  113. $confirmation_message .= "<p>" . sprintf(__('Below are details about your membership account. A welcome email has been sent to %s.', 'paid-memberships-pro' ), $current_user->user_email) . "</p>";
  114. /**
  115. * All devs to filter the confirmation message.
  116. * Documented above.
  117. * We also have a function in includes/filters.php that applies the the_content filters to this message.
  118. */
  119. $confirmation_message = apply_filters("pmpro_confirmation_message", $confirmation_message, false);
  120. echo wp_kses_post( $confirmation_message );
  121. ?>
  122. <ul>
  123. <li><strong><?php esc_html_e('Account', 'paid-memberships-pro' );?>:</strong> <?php echo esc_html( $current_user->display_name );?> (<?php echo esc_html( $current_user->user_email );?>)</li>
  124. <li><strong><?php esc_html_e('Membership Level', 'paid-memberships-pro' );?>:</strong> <?php if(!empty($current_user->membership_level)) echo esc_html( $current_user->membership_level->name ); else esc_html_e("Pending", 'paid-memberships-pro' );?></li>
  125. <?php if( !empty( $current_user->membership_level->expiration_period ) && $current_user->membership_level->expiration_period == 'Hour' && apply_filters( 'pmpro_confirmation_display_hour_expiration', true, $current_user ) ){ ?>
  126. <li><strong><?php esc_html_e('Expires In', 'paid-memberships-pro' );?>:</strong> <?php echo esc_html( $current_user->membership_level->expiration_number . ' ' . pmpro_translate_billing_period( $current_user->membership_level->expiration_period, $current_user->membership_level->expiration_number ) ); ?></li>
  127. <?php }
  128. ?>
  129. </ul>
  130. <?php
  131. }
  132. ?>
  133. <p class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav' ); ?>">
  134. <?php if ( ! empty( $current_user->membership_level ) ) { ?>
  135. <a href="<?php echo esc_url( pmpro_url( 'account' ) ); ?>"><?php esc_html_e( 'View Your Membership Account &rarr;', 'paid-memberships-pro' ); ?></a>
  136. <?php } else { ?>
  137. <?php _e( 'If your account is not activated within a few minutes, please contact the site owner.', 'paid-memberships-pro' ); ?>
  138. <?php } ?>
  139. </p> <!-- end pmpro_actions_nav -->
  140. </div> <!-- end pmpro_confirmation_wrap -->