diff --git a/classes/class.pmprogateway_pbc.php b/classes/class.pmprogateway_pbc.php index 424b142..560b276 100644 --- a/classes/class.pmprogateway_pbc.php +++ b/classes/class.pmprogateway_pbc.php @@ -60,8 +60,9 @@ function process(&$order) { // Save the checkout data into the order. pmpro_save_checkout_data_to_order( $order ); - // Send the check_pending email. + // Send the check_pending emails. pmpropbc_send_check_pending_email( $order ); + pmpropbc_send_check_pending_admin_email( $order ); // Redirect to the confirmation page and await checkout completion. $confirmation_url = apply_filters( 'pmpro_confirmation_url', add_query_arg( 'pmpro_level', $order->membership_level->id, pmpro_url("confirmation" ) ), $order->user_id, $order->membership_level ); diff --git a/includes/emails.php b/includes/emails.php index ab0ef92..293e5d4 100644 --- a/includes/emails.php +++ b/includes/emails.php @@ -28,6 +28,19 @@ function pmpropbc_email_template_to_pmproet_add_on( $template ) {
Log in to your membership account here: !!login_link!!
', 'pmpro_pay_by_check' ), ); + $template['check_pending_admin'] = array( + 'subject' => 'Pending checkout for !!display_name!! at !!sitename!!', + 'description' => 'Pay By Check - Check Pending Admin', + 'body' => __( 'There is a pending checkout at !!sitename!!.
+ +Account: !!display_name!! (!!user_email!!)
+Membership Level: !!membership_level_name!!
+ +
+ Invoice #!!invoice_id!! on !!invoice_date!!
+ Total Billed: !!invoice_total!!
+
" . __("Discount Code", "pmpro") . ": " . $order->discount_code->code . "
\n"; + $email->data["discount_code"] = "" . __("Discount Code", "pmpro-pay-by-check") . ": " . $order->discount_code->code . "
\n"; + else + $email->data["discount_code"] = ""; + + //send the email + return $email->sendEmail(); +} + +/** + * Send the check_pending_admin email. + * + * @since TBD + * + * @param MemberOrder $order - The order object. + * @return bool - True if the email was sent, false otherwise. + */ +function pmpropbc_send_check_pending_admin_email( $order ) { + // Get the user. + $user = get_userdata( $order->user_id ); + if ( empty( $user ) ) { + return false; + } + + // Get the membership level. + $level = $order->getMembershipLevel(); + if ( empty( $level ) ) { + return false; + } + + $email = new PMProEmail(); + $email->template = "check_pending_admin"; + $email->email = get_bloginfo("admin_email"); + $email->subject = sprintf(__("Pending checkout for !!display_name!! at !!sitename!!", "pmpro-pay-by-check"), $level->name, get_option("blogname")); + + //setup more data + $email->data = array( + "name" => $user->display_name, + "user_login" => $user->user_login, + "sitename" => get_option("blogname"), + "siteemail" => pmpro_getOption("from_email"), + "membership_id" => $level->id, + "membership_level_name" => $level->name, + "membership_cost" => pmpro_getLevelCost( $level ), + "login_link" => wp_login_url(pmpro_url("account")), + "display_name" => $user->display_name, + "user_email" => $user->user_email, + ); + + $email->data["instructions"] = wp_unslash( pmpro_getOption('instructions') ); + $email->data["invoice_id"] = $order->code; + $email->data["invoice_total"] = pmpro_formatPrice($order->total); + $email->data["invoice_date"] = date(get_option('date_format'), $order->timestamp); + $email->data["billing_name"] = $order->billing->name; + $email->data["billing_street"] = $order->billing->street; + $email->data["billing_city"] = $order->billing->city; + $email->data["billing_state"] = $order->billing->state; + $email->data["billing_zip"] = $order->billing->zip; + $email->data["billing_country"] = $order->billing->country; + $email->data["billing_phone"] = $order->billing->phone; + $email->data["cardtype"] = $order->cardtype; + $email->data["accountnumber"] = hideCardNumber($order->accountnumber); + $email->data["expirationmonth"] = $order->expirationmonth; + $email->data["expirationyear"] = $order->expirationyear; + $email->data["billing_address"] = pmpro_formatAddress($order->billing->name, + $order->billing->street, + "", //address 2 + $order->billing->city, + $order->billing->state, + $order->billing->zip, + $order->billing->country, + $order->billing->phone); + + if($order->getDiscountCode()) + $email->data["discount_code"] = "" . __("Discount Code", "pmpro-pay-by-check") . ": " . $order->discount_code->code . "
\n"; else $email->data["discount_code"] = "";