$user = get_userdata($user_id); if (!empty($old_order->id)) { do_action("pmpro_subscription_payment_failed", $old_order); //prep this order for the failure emails $morder = new MemberOrder(); $morder->user_id = $user_id; $morder->billing->name = $old_order->billing->name; $morder->billing->street = $old_order->billing->street; $morder->billing->city = $old_order->billing->city; $morder->billing->state = $old_order->billing->state; $morder->billing->zip = $old_order->billing->zip; $morder->billing->country = $old_order->billing->country; $morder->billing->phone = $old_order->billing->phone; //get CC info that is on file $morder->cardtype = get_user_meta($user_id, "pmpro_CardType", true); $morder->accountnumber = hideCardNumber(get_user_meta($user_id, "pmpro_AccountNumber", true), false); $morder->expirationmonth = get_user_meta($user_id, "pmpro_ExpirationMonth", true); $morder->expirationyear = get_user_meta($user_id, "pmpro_ExpirationYear", true); // Email the user and ask them to update their credit card information $pmproemail = new PMProEmail(); $pmproemail->sendBillingFailureEmail($user, $morder); // Email admin so they are aware of the failure $pmproemail = new PMProEmail(); $pmproemail->sendBillingFailureAdminEmail(get_bloginfo("admin_email"), $morder); $logstr .= "Subscription payment failed on order ID #" . $old_order->id . ". Sent email to the member and site admin."; pmpro_stripeWebhookExit(); } else { $logstr .= "Could not find the related subscription for event with ID #" . $event->id . "."; if (!empty($event->data->object->customer)) { $logstr .= " Customer ID #" . $event->data->object->customer . "."; }
function pmproet_email_data($data, $email) { global $current_user, $pmpro_currency_symbol, $wpdb; if (!empty($data) && !empty($data['user_login'])) { $user = get_user_by('login', $data['user_login']); } if (empty($user)) { $user = $current_user; } $pmpro_user_meta = $wpdb->get_row("SELECT * FROM {$wpdb->pmpro_memberships_users} WHERE user_id = '" . $user->ID . "' AND status='active'"); //make sure data is an array if (!is_array($data)) { $data = array(); } //general data $new_data['sitename'] = get_option("blogname"); $new_data['siteemail'] = pmpro_getOption("from_email"); if (empty($new_data['login_link'])) { $new_data['login_link'] = wp_login_url(); } $new_data['levels_link'] = pmpro_url("levels"); //user data if (!empty($user)) { $new_data['name'] = $user->display_name; $new_data['user_login'] = $user->user_login; $new_data['display_name'] = $user->display_name; $new_data['user_email'] = $user->user_email; } //membership data if (!empty($user->membership_level)) { $new_data['enddate'] = date(get_option('date_format'), $user->membership_level->enddate); } //invoice data if (!empty($data['invoice_id'])) { $invoice = new MemberOrder($data['invoice_id']); if (!empty($invoice)) { $new_data['billing_name'] = $invoice->billing->name; $new_data['billing_street'] = $invoice->billing->street; $new_data['billing_city'] = $invoice->billing->city; $new_data['billing_state'] = $invoice->billing->state; $new_data['billing_zip'] = $invoice->billing->zip; $new_data['billing_country'] = $invoice->billing->country; $new_data['billing_phone'] = $invoice->billing->phone; $new_data['cardtype'] = $invoice->cardtype; $new_data['accountnumber'] = hideCardNumber($invoice->accountnumber); $new_data['expirationmonth'] = $invoice->expirationmonth; $new_data['expirationyear'] = $invoice->expirationyear; $new_data['instructions'] = wpautop(pmpro_getOption('instructions')); $new_data['invoice_id'] = $invoice->code; $new_data['invoice_total'] = $pmpro_currency_symbol . number_format($invoice->total, 2); $new_data['invoice_link'] = pmpro_url('invoice', '?invoice=' . $invoice->code); //billing address $new_data["billing_address"] = pmpro_formatAddress($invoice->billing->name, $invoice->billing->street, "", $invoice->billing->city, $invoice->billing->state, $invoice->billing->zip, $invoice->billing->country, $invoice->billing->phone); } } //membership change if (!empty($user->membership_level) && !empty($user->membership_level->ID)) { $new_data["membership_change"] = sprintf(__("The new level is %s.", "pmpro"), $user->membership_level->name); } else { $new_data["membership_change"] = __("Your membership has been cancelled", "pmpro"); } if (!empty($user->membership_level) && !empty($user->membership_level->enddate)) { $new_data["membership_change"] .= ". " . sprintf(__("This membership will expire on %s", "pmpro"), date(get_option('date_format'), $user->membership_level->enddate)); } elseif (!empty($email->expiration_changed)) { $new_data["membership_change"] .= ". " . __("This membership does not expire", "pmpro"); } //membership expiration $new_data['membership_expiration'] = ''; if (!empty($pmpro_user_meta->enddate)) { $new_data['membership_expiration'] = "<p>" . sprintf(__("This membership will expire on %s.", "pmpro"), $pmpro_user_meta->enddate . "</p>\n"); } //if others are used in the email look in usermeta $et_body = pmpro_getOption('email_' . $email->template . '_body'); $templates_in_email = preg_match_all("/!!([^!]+)!!/", $et_body, $matches); if (!empty($templates_in_email)) { $matches = $matches[1]; foreach ($matches as $match) { if (empty($new_data[$match])) { $usermeta = get_user_meta($user->ID, $match, true); if (!empty($usermeta)) { if (is_array($usermeta) && !empty($usermeta['fullurl'])) { $new_data[$match] = $usermeta['fullurl']; } elseif (is_array($usermeta)) { $new_data[$match] = implode(", ", $usermeta); } else { $new_data[$match] = $usermeta; } } } } } //now replace any new_data not already in data foreach ($new_data as $key => $value) { if (!isset($data[$key])) { $data[$key] = $value; } } return $data; }
/** * Save/update the values of the order in the database. */ function saveOrder() { global $current_user, $wpdb; //get a random code to use for the public ID if (empty($this->code)) { $this->code = $this->getRandomCode(); } //figure out how much we charged if (!empty($this->InitialPayment)) { $amount = $this->InitialPayment; } elseif (!empty($this->subtotal)) { $amount = $this->subtotal; } else { $amount = 0; } //Todo: Tax?!, Coupons, Certificates, affiliates if (empty($this->subtotal)) { $this->subtotal = $amount; } if (isset($this->tax)) { $tax = $this->tax; } else { $tax = $this->getTax(true); } $this->certificate_id = ""; $this->certificateamount = ""; //calculate total if (!empty($this->total)) { $total = $this->total; } else { $total = (double) $amount + (double) $tax; } //these fix some warnings/notices if (empty($this->billing)) { $this->billing = new stdClass(); $this->billing->name = $this->billing->street = $this->billing->city = $this->billing->state = $this->billing->zip = $this->billing->country = $this->billing->phone = ""; } if (empty($this->user_id)) { $this->user_id = 0; } if (empty($this->paypal_token)) { $this->paypal_token = ""; } if (empty($this->couponamount)) { $this->couponamount = ""; } if (empty($this->payment_type)) { $this->payment_type = ""; } if (empty($this->payment_transaction_id)) { $this->payment_transaction_id = ""; } if (empty($this->subscription_transaction_id)) { $this->subscription_transaction_id = ""; } if (empty($this->affiliate_id)) { $this->affiliate_id = ""; } if (empty($this->affiliate_subid)) { $this->affiliate_subid = ""; } if (empty($this->session_id)) { $this->session_id = ""; } if (empty($this->accountnumber)) { $this->accountnumber = ""; } if (empty($this->cardtype)) { $this->cardtype = ""; } if (empty($this->ExpirationDate)) { $this->ExpirationDate = ""; } if (empty($this->status)) { $this->status = ""; } if (empty($this->gateway)) { $this->gateway = pmpro_getOption("gateway"); } if (empty($this->gateway_environment)) { $this->gateway_environment = pmpro_getOption("gateway_environment"); } if (empty($this->notes)) { $this->notes = ""; } //build query if (!empty($this->id)) { //set up actions $before_action = "pmpro_update_order"; $after_action = "pmpro_updated_order"; //update $this->sqlQuery = "UPDATE {$wpdb->pmpro_membership_orders}\n\t\t\t\t\t\t\t\t\tSET `code` = '" . $this->code . "',\n\t\t\t\t\t\t\t\t\t`session_id` = '" . $this->session_id . "',\n\t\t\t\t\t\t\t\t\t`user_id` = " . intval($this->user_id) . ",\n\t\t\t\t\t\t\t\t\t`membership_id` = " . intval($this->membership_id) . ",\n\t\t\t\t\t\t\t\t\t`paypal_token` = '" . $this->paypal_token . "',\n\t\t\t\t\t\t\t\t\t`billing_name` = '" . esc_sql($this->billing->name) . "',\n\t\t\t\t\t\t\t\t\t`billing_street` = '" . esc_sql($this->billing->street) . "',\n\t\t\t\t\t\t\t\t\t`billing_city` = '" . esc_sql($this->billing->city) . "',\n\t\t\t\t\t\t\t\t\t`billing_state` = '" . esc_sql($this->billing->state) . "',\n\t\t\t\t\t\t\t\t\t`billing_zip` = '" . esc_sql($this->billing->zip) . "',\n\t\t\t\t\t\t\t\t\t`billing_country` = '" . esc_sql($this->billing->country) . "',\n\t\t\t\t\t\t\t\t\t`billing_phone` = '" . esc_sql($this->billing->phone) . "',\n\t\t\t\t\t\t\t\t\t`subtotal` = '" . $this->subtotal . "',\n\t\t\t\t\t\t\t\t\t`tax` = '" . $this->tax . "',\n\t\t\t\t\t\t\t\t\t`couponamount` = '" . $this->couponamount . "',\n\t\t\t\t\t\t\t\t\t`certificate_id` = " . intval($this->certificate_id) . ",\n\t\t\t\t\t\t\t\t\t`certificateamount` = '" . $this->certificateamount . "',\n\t\t\t\t\t\t\t\t\t`total` = '" . $this->total . "',\n\t\t\t\t\t\t\t\t\t`payment_type` = '" . $this->payment_type . "',\n\t\t\t\t\t\t\t\t\t`cardtype` = '" . $this->cardtype . "',\n\t\t\t\t\t\t\t\t\t`accountnumber` = '" . $this->accountnumber . "',\n\t\t\t\t\t\t\t\t\t`expirationmonth` = '" . $this->expirationmonth . "',\n\t\t\t\t\t\t\t\t\t`expirationyear` = '" . $this->expirationyear . "',\n\t\t\t\t\t\t\t\t\t`status` = '" . esc_sql($this->status) . "',\n\t\t\t\t\t\t\t\t\t`gateway` = '" . $this->gateway . "',\n\t\t\t\t\t\t\t\t\t`gateway_environment` = '" . $this->gateway_environment . "',\n\t\t\t\t\t\t\t\t\t`payment_transaction_id` = '" . esc_sql($this->payment_transaction_id) . "',\n\t\t\t\t\t\t\t\t\t`subscription_transaction_id` = '" . esc_sql($this->subscription_transaction_id) . "',\n\t\t\t\t\t\t\t\t\t`affiliate_id` = '" . esc_sql($this->affiliate_id) . "',\n\t\t\t\t\t\t\t\t\t`affiliate_subid` = '" . esc_sql($this->affiliate_subid) . "',\n\t\t\t\t\t\t\t\t\t`notes` = '" . esc_sql($this->notes) . "'\n\t\t\t\t\t\t\t\t\tWHERE id = '" . $this->id . "'\n\t\t\t\t\t\t\t\t\tLIMIT 1"; } else { //set up actions $before_action = "pmpro_add_order"; $after_action = "pmpro_added_order"; //insert $this->sqlQuery = "INSERT INTO {$wpdb->pmpro_membership_orders}\n\t\t\t\t\t\t\t\t(`code`, `session_id`, `user_id`, `membership_id`, `paypal_token`, `billing_name`, `billing_street`, `billing_city`, `billing_state`, `billing_zip`, `billing_country`, `billing_phone`, `subtotal`, `tax`, `couponamount`, `certificate_id`, `certificateamount`, `total`, `payment_type`, `cardtype`, `accountnumber`, `expirationmonth`, `expirationyear`, `status`, `gateway`, `gateway_environment`, `payment_transaction_id`, `subscription_transaction_id`, `timestamp`, `affiliate_id`, `affiliate_subid`, `notes`)\n\t\t\t\t\t\t\t\tVALUES('" . $this->code . "',\n\t\t\t\t\t\t\t\t\t '" . session_id() . "',\n\t\t\t\t\t\t\t\t\t " . intval($this->user_id) . ",\n\t\t\t\t\t\t\t\t\t " . intval($this->membership_id) . ",\n\t\t\t\t\t\t\t\t\t '" . $this->paypal_token . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql(trim($this->billing->name)) . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql(trim($this->billing->street)) . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql($this->billing->city) . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql($this->billing->state) . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql($this->billing->zip) . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql($this->billing->country) . "',\n\t\t\t\t\t\t\t\t\t '" . cleanPhone($this->billing->phone) . "',\n\t\t\t\t\t\t\t\t\t '" . $amount . "',\n\t\t\t\t\t\t\t\t\t '" . $tax . "',\n\t\t\t\t\t\t\t\t\t '" . $this->couponamount . "',\n\t\t\t\t\t\t\t\t\t " . intval($this->certificate_id) . ",\n\t\t\t\t\t\t\t\t\t '" . $this->certificateamount . "',\n\t\t\t\t\t\t\t\t\t '" . $total . "',\n\t\t\t\t\t\t\t\t\t '" . $this->payment_type . "',\n\t\t\t\t\t\t\t\t\t '" . $this->cardtype . "',\n\t\t\t\t\t\t\t\t\t '" . hideCardNumber($this->accountnumber, false) . "',\n\t\t\t\t\t\t\t\t\t '" . substr($this->ExpirationDate, 0, 2) . "',\n\t\t\t\t\t\t\t\t\t '" . substr($this->ExpirationDate, 2, 4) . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql($this->status) . "',\n\t\t\t\t\t\t\t\t\t '" . $this->gateway . "',\n\t\t\t\t\t\t\t\t\t '" . $this->gateway_environment . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql($this->payment_transaction_id) . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql($this->subscription_transaction_id) . "',\n\t\t\t\t\t\t\t\t\t '" . current_time('mysql') . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql($this->affiliate_id) . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql($this->affiliate_subid) . "',\n\t\t\t\t\t\t\t\t\t '" . esc_sql($this->notes) . "'\n\t\t\t\t\t\t\t\t\t )"; } do_action($before_action, $this); if ($wpdb->query($this->sqlQuery) !== false) { if (empty($this->id)) { $this->id = $wpdb->insert_id; } do_action($after_action, $this); return $this->getMemberOrderByID($this->id); } else { return false; } }
$worked = $morder->updateBilling(); if ($worked) { //send email to member $pmproemail = new PMProEmail(); $pmproemail->sendBillingEmail($current_user, $morder); //send email to admin $pmproemail = new PMProEmail(); $pmproemail->sendBillingAdminEmail($current_user, $morder); } } else { $worked = true; } if ($worked) { //update the user meta too $meta_keys = array("pmpro_bfirstname", "pmpro_blastname", "pmpro_baddress1", "pmpro_baddress2", "pmpro_bcity", "pmpro_bstate", "pmpro_bzipcode", "pmpro_bphone", "pmpro_bemail", "pmpro_CardType", "pmpro_AccountNumber", "pmpro_ExpirationMonth", "pmpro_ExpirationYear"); $meta_values = array($bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bphone, $bemail, $CardType, hideCardNumber($AccountNumber), $ExpirationMonth, $ExpirationYear); pmpro_replaceUserMeta($current_user->ID, $meta_keys, $meta_values); //message $pmpro_msg = sprintf(__('Information updated. <a href="%s">« back to my account</a>', 'pmpro'), pmpro_url("account")); $pmpro_msgt = "pmpro_success"; } else { $pmpro_msg = $morder->error; if (!$pmpro_msg) { $pmpro_msg = __("Error updating billing information.", 'pmpro'); } $pmpro_msgt = "pmpro_error"; } } } else { //default values from DB $bfirstname = get_user_meta($current_user->ID, "pmpro_bfirstname", true);
$invoices = $wpdb->get_results("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM {$wpdb->pmpro_membership_orders} WHERE user_id = '{$current_user->ID}' ORDER BY timestamp DESC LIMIT 6"); if (!empty($ssorder->id) && $ssorder->gateway != "check" && $ssorder->gateway != "paypalexpress" && $ssorder->gateway != "paypalstandard" && $ssorder->gateway != "twocheckout") { //default values from DB (should be last order or last update) $bfirstname = get_user_meta($current_user->ID, "pmpro_bfirstname", true); $blastname = get_user_meta($current_user->ID, "pmpro_blastname", true); $baddress1 = get_user_meta($current_user->ID, "pmpro_baddress1", true); $baddress2 = get_user_meta($current_user->ID, "pmpro_baddress2", true); $bcity = get_user_meta($current_user->ID, "pmpro_bcity", true); $bstate = get_user_meta($current_user->ID, "pmpro_bstate", true); $bzipcode = get_user_meta($current_user->ID, "pmpro_bzipcode", true); $bcountry = get_user_meta($current_user->ID, "pmpro_bcountry", true); $bphone = get_user_meta($current_user->ID, "pmpro_bphone", true); $bemail = get_user_meta($current_user->ID, "pmpro_bemail", true); $bconfirmemail = get_user_meta($current_user->ID, "pmpro_bconfirmemail", true); $CardType = get_user_meta($current_user->ID, "pmpro_CardType", true); $AccountNumber = hideCardNumber(get_user_meta($current_user->ID, "pmpro_AccountNumber", true), false); $ExpirationMonth = get_user_meta($current_user->ID, "pmpro_ExpirationMonth", true); $ExpirationYear = get_user_meta($current_user->ID, "pmpro_ExpirationYear", true); ?> <div id="pmpro_account-billing" class="pmpro_box"> <h3><?php _e("Billing Information", "pmpro"); ?> </h3> <?php if (!empty($baddress1)) { ?> <p> <strong><?php
function pmpro_ipnSaveOrder($txn_id, $last_order) { global $wpdb; //check that txn_id has not been previously processed $old_txn = $wpdb->get_var("SELECT payment_transaction_id FROM {$wpdb->pmpro_membership_orders} WHERE payment_transaction_id = '" . $txn_id . "' LIMIT 1"); if (empty($old_txn)) { //hook for successful subscription payments do_action("pmpro_subscription_payment_completed"); //save order $morder = new MemberOrder(); $morder->user_id = $last_order->user_id; $morder->membership_id = $last_order->membership_id; $morder->payment_transaction_id = $txn_id; $morder->subscription_transaction_id = $last_order->subscription_transaction_id; $morder->gateway = $last_order->gateway; $morder->gateway_environment = $last_order->gateway_environment; // Payment Status $morder->status = 'success'; // We have confirmed that and thats the reason we are here. // Payment Type. $morder->payment_type = $last_order->payment_type; //set amount based on which PayPal type if ($last_order->gateway == "paypal") { $morder->InitialPayment = $_POST['amount']; //not the initial payment, but the class is expecting that $morder->PaymentAmount = $_POST['amount']; } elseif ($last_order->gateway == "paypalexpress") { $morder->InitialPayment = $_POST['amount']; //not the initial payment, but the class is expecting that $morder->PaymentAmount = $_POST['amount']; } elseif ($last_order->gateway == "paypalstandard") { $morder->InitialPayment = $_POST['mc_gross']; //not the initial payment, but the class is expecting that $morder->PaymentAmount = $_POST['mc_gross']; } $morder->FirstName = $_POST['first_name']; $morder->LastName = $_POST['last_name']; $morder->Email = $_POST['payer_email']; //get address info if appropriate if ($last_order->gateway == "paypal") { $morder->Address1 = get_user_meta($last_order->user_id, "pmpro_baddress1", true); $morder->City = get_user_meta($last_order->user_id, "pmpro_bcity", true); $morder->State = get_user_meta($last_order->user_id, "pmpro_bstate", true); $morder->CountryCode = "US"; $morder->Zip = get_user_meta($last_order->user_id, "pmpro_bzip", true); $morder->PhoneNumber = get_user_meta($last_order->user_id, "pmpro_bphone", true); $morder->billing->name = $_POST['first_name'] . " " . $_POST['last_name']; $morder->billing->street = get_user_meta($last_order->user_id, "pmpro_baddress1", true); $morder->billing->city = get_user_meta($last_order->user_id, "pmpro_bcity", true); $morder->billing->state = get_user_meta($last_order->user_id, "pmpro_bstate", true); $morder->billing->zip = get_user_meta($last_order->user_id, "pmpro_bzip", true); $morder->billing->country = get_user_meta($last_order->user_id, "pmpro_bcountry", true); $morder->billing->phone = get_user_meta($last_order->user_id, "pmpro_bphone", true); //get CC info that is on file $morder->cardtype = get_user_meta($last_order->user_id, "pmpro_CardType", true); $morder->accountnumber = hideCardNumber(get_user_meta($last_order->user_id, "pmpro_AccountNumber", true), false); $morder->expirationmonth = get_user_meta($last_order->user_id, "pmpro_ExpirationMonth", true); $morder->expirationyear = get_user_meta($last_order->user_id, "pmpro_ExpirationYear", true); $morder->ExpirationDate = $morder->expirationmonth . $morder->expirationyear; $morder->ExpirationDate_YdashM = $morder->expirationyear . "-" . $morder->expirationmonth; } //save $morder->saveOrder(); $morder->getMemberOrderByID($morder->id); //email the user their invoice $pmproemail = new PMProEmail(); $pmproemail->sendInvoiceEmail(get_userdata($last_order->user_id), $morder); ipnlog("New order (" . $morder->code . ") created."); return true; } else { ipnlog("Duplicate Transaction ID: " . $txn_id); return false; } }
function sendInvoiceEmail($user = NULL, $invoice = NULL) { global $wpdb, $current_user, $pmpro_currency_symbol; if(!$user) $user = $current_user; if(!$user || !$invoice) return false; $this->email = $user->user_email; $this->subject = "INVOICE for " . get_option("blogname") . " membership"; $this->template = "invoice"; $this->data = array( "subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"), "membership_level_name" => $user->membership_level->name, "display_name" => $user->display_name, "user_email" => $user->user_email, "invoice_id" => $invoice->payment_transaction_id, "invoice_total" => $pmpro_currency_symbol . number_format($invoice->total, 2), "invoice_date" => date(get_option('date_format'), $invoice->timestamp), "billing_name" => $invoice->billing->name, "billing_street" => $invoice->billing->street, "billing_city" => $invoice->billing->city, "billing_state" => $invoice->billing->state, "billing_zip" => $invoice->billing->zip, "billing_country" => $invoice->billing->country, "billing_phone" => $invoice->billing->phone, "cardtype" => $invoice->cardtype, "accountnumber" => hideCardNumber($invoice->accountnumber), "expirationmonth" => $invoice->expirationmonth, "expirationyear" => $invoice->expirationyear, "login_link" => pmpro_url("account"), "invoice_link" => pmpro_url("invoice", "?invoice=" . $invoice->code) ); if($invoice->getDiscountCode()) $this->data["discount_code"] = "<p>Discount Code: " . $invoice->discount_code . "</p>\n"; else $this->data["discount_code"] = ""; $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1"); if($enddate) $this->data["membership_expiration"] = "<p>This membership will expire on " . date(get_option('date_format'), $enddate) . ".</p>\n"; else $this->data["membership_expiration"] = ""; return $this->sendEmail(); }
function sendInvoiceEmail($user = NULL, $invoice = NULL) { global $wpdb, $current_user; if (!$user) { $user = $current_user; } if (!$user || !$invoice) { return false; } $user->membership_level = pmpro_getMembershipLevelForUser($user->ID); $this->email = $user->user_email; $this->subject = sprintf(__("INVOICE for %s membership", "pmpro"), get_option("blogname")); $this->template = "invoice"; $this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"), "membership_id" => $user->membership_level->id, "membership_level_name" => $user->membership_level->name, "display_name" => $user->display_name, "user_email" => $user->user_email, "invoice_id" => $invoice->code, "invoice_total" => pmpro_formatPrice($invoice->total), "invoice_date" => date_i18n(get_option('date_format'), $invoice->timestamp), "billing_name" => $invoice->billing->name, "billing_street" => $invoice->billing->street, "billing_city" => $invoice->billing->city, "billing_state" => $invoice->billing->state, "billing_zip" => $invoice->billing->zip, "billing_country" => $invoice->billing->country, "billing_phone" => $invoice->billing->phone, "cardtype" => $invoice->cardtype, "accountnumber" => hideCardNumber($invoice->accountnumber), "expirationmonth" => $invoice->expirationmonth, "expirationyear" => $invoice->expirationyear, "login_link" => wp_login_url(pmpro_url("account")), "invoice_link" => wp_login_url(pmpro_url("invoice", "?invoice=" . $invoice->code))); $this->data["billing_address"] = pmpro_formatAddress($invoice->billing->name, $invoice->billing->street, "", $invoice->billing->city, $invoice->billing->state, $invoice->billing->zip, $invoice->billing->country, $invoice->billing->phone); if ($invoice->getDiscountCode()) { $this->data["discount_code"] = "<p>" . __("Discount Code", "pmpro") . ": " . $invoice->discount_code . "</p>\n"; } else { $this->data["discount_code"] = ""; } $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM {$wpdb->pmpro_memberships_users} WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1"); if ($enddate) { $this->data["membership_expiration"] = "<p>" . sprintf(__("This membership will expire on %s.", "pmpro"), date_i18n(get_option('date_format'), $enddate)) . "</p>\n"; } else { $this->data["membership_expiration"] = ""; } return $this->sendEmail(); }
function billing_content_func($atts) { global $wpdb, $pmpro_msg, $pmpro_msgt, $pmpro_levels, $current_user, $levels; //-> If a member is logged in, show them some info here (1. past invoices. 2. billing information with button to update.) if ($current_user->membership_level->ID) { if ($pmpro_msg) { ?> <div class="pmpro_message <?php echo $pmpro_msgt; ?> "><?php echo $pmpro_msg; ?> </div> <?php } ?> <div class="row billing-content"> <div class="col-md-8 col-sm-8 col-sm-offset-3 col-md-offset-3"> <!-- BEGIN CONTENT--> <div id="pmpro_account"> <div id="pmpro_account-membership" class="pmpro_box-first"> <?php //wpex_logo(); ?> <!-- <div class="clear clearfix"></div> <br/> --> <?php $level = $current_user->membership_level->name; ?> <p><?php _e("Membership status: <strong>" . $level . "</strong>", "pmpro"); ?> </p> <?php //die(var_dump($current_user)); ?> <ul> <li><strong><?php _e("Level", "pmpro"); ?> :</strong> <?php echo $current_user->membership_level->name; ?> </li> <?php if ($current_user->membership_level->billing_amount > 0) { ?> <li><strong><?php _e("Membership Fee", "pmpro"); ?> :</strong> <?php $level = $current_user->membership_level; if ($current_user->membership_level->cycle_number > 1) { printf(__('%s every %d %s.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number)); } elseif ($current_user->membership_level->cycle_number == 1) { printf(__('%s per %s.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period)); } else { echo pmpro_formatPrice($current_user->membership_level->billing_amount); } ?> </li> <?php } ?> <?php if ($current_user->membership_level->billing_limit) { ?> <li><strong><?php _e("Duration", "pmpro"); ?> :</strong> <?php echo $current_user->membership_level->billing_limit . ' ' . sornot($current_user->membership_level->cycle_period, $current_user->membership_level->billing_limit); ?> </li> <?php } ?> <?php if ($current_user->membership_level->enddate) { ?> <li><strong><?php _e("Next billing date", "pmpro"); ?> :</strong> <?php echo date_i18n(get_option('date_format'), $current_user->membership_level->enddate); ?> </li> <?php } ?> <?php if ($current_user->membership_level->trial_limit == 1) { printf(__("Your first payment will cost %s.", "pmpro"), pmpro_formatPrice($current_user->membership_level->trial_amount)); } elseif (!empty($current_user->membership_level->trial_limit)) { printf(__("Your first %d payments will cost %s.", "pmpro"), $current_user->membership_level->trial_limit, pmpro_formatPrice($current_user->membership_level->trial_amount)); } ?> </ul> </div> <!-- end pmpro_account-membership --> <div id="pmpro_account-profile" class="pmpro_box hide"> <?php get_currentuserinfo(); ?> <h3><?php _e("My Account", "pmpro"); ?> </h3> <?php if ($current_user->user_firstname) { ?> <p><?php echo $current_user->user_firstname; ?> <?php echo $current_user->user_lastname; ?> </p> <?php } ?> <ul> <li><strong><?php _e("Username", "pmpro"); ?> :</strong> <?php echo $current_user->user_login; ?> </li> <li><strong><?php _e("Email", "pmpro"); ?> :</strong> <?php echo $current_user->user_email; ?> </li> </ul> <p> <a href="<?php echo admin_url('profile.php'); ?> "><?php _e("Edit Profile", "pmpro"); ?> </a> | <a href="<?php echo admin_url('profile.php'); ?> "><?php _ex("Change Password", "As in 'change password'.", "pmpro"); ?> </a> </p> </div> <!-- end pmpro_account-profile --> <?php //last invoice for current info //$ssorder = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM $wpdb->pmpro_membership_orders WHERE user_id = '$current_user->ID' AND membership_id = '" . $current_user->membership_level->ID . "' AND status = 'success' ORDER BY timestamp DESC LIMIT 1"); $ssorder = new MemberOrder(); $ssorder->getLastMemberOrder(); $invoices = $wpdb->get_results("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM {$wpdb->pmpro_membership_orders} WHERE user_id = '{$current_user->ID}' ORDER BY timestamp DESC LIMIT 6"); if (!empty($ssorder->id) && $ssorder->gateway != "check" && $ssorder->gateway != "paypalexpress" && $ssorder->gateway != "paypalstandard" && $ssorder->gateway != "twocheckout") { //default values from DB (should be last order or last update) $bfirstname = get_user_meta($current_user->ID, "pmpro_bfirstname", true); $blastname = get_user_meta($current_user->ID, "pmpro_blastname", true); $baddress1 = get_user_meta($current_user->ID, "pmpro_baddress1", true); $baddress2 = get_user_meta($current_user->ID, "pmpro_baddress2", true); $bcity = get_user_meta($current_user->ID, "pmpro_bcity", true); $bstate = get_user_meta($current_user->ID, "pmpro_bstate", true); $bzipcode = get_user_meta($current_user->ID, "pmpro_bzipcode", true); $bcountry = get_user_meta($current_user->ID, "pmpro_bcountry", true); $bphone = get_user_meta($current_user->ID, "pmpro_bphone", true); $bemail = get_user_meta($current_user->ID, "pmpro_bemail", true); $bconfirmemail = get_user_meta($current_user->ID, "pmpro_bconfirmemail", true); $CardType = get_user_meta($current_user->ID, "pmpro_CardType", true); $AccountNumber = hideCardNumber(get_user_meta($current_user->ID, "pmpro_AccountNumber", true), false); $ExpirationMonth = get_user_meta($current_user->ID, "pmpro_ExpirationMonth", true); $ExpirationYear = get_user_meta($current_user->ID, "pmpro_ExpirationYear", true); ?> <div id="pmpro_account-billing" class="pmpro_box"> <h3><?php _e("Billing Information", "pmpro"); ?> </h3> <?php if (!empty($baddress1)) { ?> <p> <strong><?php _e("Billing Address", "pmpro"); ?> </strong><br /> <?php echo $bfirstname . " " . $blastname; ?> <br /> <?php echo $current_user->user_email; ?> <br /> <?php echo $baddress1; ?> <br /> <?php if ($baddress2) { echo $baddress2 . "<br />"; } ?> <?php if ($bcity && $bstate) { ?> <?php echo $bcity; ?> , <?php echo $bstate; ?> <?php echo $bzipcode; ?> <?php echo $bcountry; ?> <?php } ?> <br /> <?php echo formatPhone($bphone); ?> </p> <?php } ?> <?php if (!empty($AccountNumber)) { ?> <p> <strong><?php _e("Payment Method", "pmpro"); ?> </strong><br /> <?php echo $CardType; ?> : <?php echo last4($AccountNumber); ?> (<?php echo $ExpirationMonth; ?> /<?php echo $ExpirationYear; ?> ) </p> <?php } ?> <?php if (isset($ssorder->status) && $ssorder->status == "success" && (isset($ssorder->gateway) && in_array($ssorder->gateway, array("authorizenet", "paypal", "stripe", "braintree", "payflow", "cybersource")))) { ?> <p><a href="<?php echo pmpro_url("billing", ""); ?> "><?php _e("Edit Billing Information", "pmpro"); ?> </a></p> <?php } ?> </div> <!-- end pmpro_account-billing --> <?php } ?> <?php if (!empty($invoices)) { ?> <div id="pmpro_account-invoices" class="pmpro_box"> <h3><?php _e("Past Invoices", "pmpro"); ?> </h3> <ul> <?php $count = 0; foreach ($invoices as $invoice) { if ($count++ > 5) { break; } ?> <li><a href="<?php echo pmpro_url("invoice", "?invoice=" . $invoice->code); ?> "><?php echo date_i18n(get_option("date_format"), $invoice->timestamp); ?> (<?php echo pmpro_formatPrice($invoice->total); ?> )</a></li> <?php } ?> </ul> <?php //if ($count == 6) { ?> <p><a href="<?php echo pmpro_url("invoice"); ?> "><?php _e("View All Invoices", "pmpro"); ?> </a></p> <?php //} ?> </div> <!-- end pmpro_account-billing --> <?php } ?> <!-- <p class="help-block">We have the following subscriptions available for our site. To join, simply click on the <strong>Change Subscription</strong> button to Change Membership Level.</p> --> <?php //getLevels(); ?> </div> <!-- end pmpro_account --> <!-- END CONTENT--> </div> </div> <?php } else { $user_id = $current_user->ID; //make sure we only run once a day $today = date("Y-m-d", current_time("timestamp")); //look for memberships that expired $sqlQuery = "SELECT mu.user_id, mu.membership_id, mu.startdate, mu.enddate FROM {$wpdb->pmpro_memberships_users} mu WHERE mu.status = 'expired' AND mu.enddate IS NOT NULL AND mu.enddate <> '' AND mu.enddate <> '0000-00-00 00:00:00' AND DATE(mu.enddate) <= '" . $today . "' AND mu.user_id = '" . $user_id . "' ORDER BY mu.enddate LIMIT 1"; $expired = $wpdb->get_results($sqlQuery); if (count($expired) > 0) { ?> <div class="row billing-content"> <div class="col-md-8 col-sm-8 col-sm-offset-3 col-md-offset-3"> <!-- BEGIN CONTENT--> <div id="pmpro_account"> <div id="pmpro_account-membership" class="pmpro_box-first"> <?php foreach ($expired as $e) { $level_id = $e->membership_id; $level = pmpro_getLevel($level_id); ?> <div class="pmpro_message">Your "<?php echo $level->name; ?> " Membership has expired, please renew now <a href="<?php echo pmpro_url("levels"); ?> "><?php _e("here", "pmpro"); ?> </a>.</div> <div id="pmpro_account-membership" class="pmpro_box-first"> <?php $level = $current_user->membership_level->name; ?> <p><?php _e("Membership status: <strong>" . $level->name . "(Expired)</strong>", "pmpro"); ?> </p> <ul> <?php if ($e->enddate) { //die(var_dump($e->enddate)); ?> <li><strong><?php _e("Expiration billing date", "pmpro"); ?> : </strong> <?php echo " " . date_i18n(get_option('date_format'), strtotime($e->enddate)); ?> </li> <?php } ?> </ul> </div> <!-- end pmpro_account-membership --> <?php } ?> </div> </div> </div> </div> <?php } } ?> <?php }
function pmpropbc_reminder_emails() { global $wpdb; //make sure we only run once a day $now = current_time('timestamp'); $today = date("Y-m-d", $now); //have to run for each level, so get levels $levels = pmpro_getAllLevels(true, true); if (empty($levels)) { return; } foreach ($levels as $level) { //get options $options = pmpropbc_getOptions($level->id); if (!empty($options['reminder_days'])) { $date = date("Y-m-d", strtotime("+ " . $options['reminder_days'] . " days", $now)); } else { $date = $today; } //need to get all combos of pay cycle and period $sqlQuery = "SELECT DISTINCT(CONCAT(cycle_number, ' ', cycle_period)) FROM {$wpdb->pmpro_memberships_users} WHERE membership_id = '" . $level->id . "' AND cycle_number > 0 AND status = 'active'"; $combos = $wpdb->get_col($sqlQuery); if (empty($combos)) { continue; } foreach ($combos as $combo) { //get all check orders still pending after X days $sqlQuery = "\r\n\t\t\t\tSELECT id \r\n\t\t\t\tFROM {$wpdb->pmpro_membership_orders} \r\n\t\t\t\tWHERE membership_id = {$level->id} \r\n\t\t\t\t\tAND gateway = 'check' \r\n\t\t\t\t\tAND status = 'pending' \r\n\t\t\t\t\tAND DATE_ADD(timestamp, INTERVAL {$combo}) <= '" . $date . "'\r\n\t\t\t\t\tAND notes NOT LIKE '%Reminder Sent:%' AND notes NOT LIKE '%Reminder Skipped:%'\r\n\t\t\t\tORDER BY id\r\n\t\t\t"; if (defined('PMPRO_CRON_LIMIT')) { $sqlQuery .= " LIMIT " . PMPRO_CRON_LIMIT; } $orders = $wpdb->get_col($sqlQuery); if (empty($orders)) { continue; } foreach ($orders as $order_id) { //get some data $order = new MemberOrder($order_id); $user = get_userdata($order->user_id); $user->membership_level = pmpro_getMembershipLevelForUser($order->user_id); //if they are no longer a member, let's not send them an email if (empty($user->membership_level) || empty($user->membership_level->ID) || $user->membership_level->id != $order->membership_id) { //note when we send the reminder $new_notes = $order->notes . "Reminder Skipped:" . $today . "\n"; $wpdb->query("UPDATE {$wpdb->pmpro_membership_orders} SET notes = '" . esc_sql($new_notes) . "' WHERE id = '" . $order_id . "' LIMIT 1"); continue; } //note when we send the reminder $new_notes = $order->notes . "Reminder Sent:" . $today . "\n"; $wpdb->query("UPDATE {$wpdb->pmpro_membership_orders} SET notes = '" . esc_sql($new_notes) . "' WHERE id = '" . $order_id . "' LIMIT 1"); //setup email to send $email = new PMProEmail(); $email->template = "check_pending_reminder"; $email->email = $user->user_email; $email->subject = sprintf(__("Reminder: New Invoice for %s at %s", "pmpropbc"), $user->membership_level->name, get_option("blogname")); //get body from template $email->body = file_get_contents(PMPRO_PAY_BY_CHECK_DIR . "/email/" . $email->template . ".html"); //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" => $user->membership_level->id, "membership_level_name" => $user->membership_level->name, "membership_cost" => pmpro_getLevelCost($user->membership_level), "login_link" => wp_login_url(pmpro_url("account")), "display_name" => $user->display_name, "user_email" => $user->user_email); $email->data["instructions"] = 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, "", $order->billing->city, $order->billing->state, $order->billing->zip, $order->billing->country, $order->billing->phone); if ($order->getDiscountCode()) { $email->data["discount_code"] = "<p>" . __("Discount Code", "pmpro") . ": " . $order->discount_code->code . "</p>\n"; } else { $email->data["discount_code"] = ""; } //send the email $email->sendEmail(); } } } }
function pmpro_ipnSaveOrder($txn_id, $last_order) { global $wpdb; //check that txn_id has not been previously processed $old_txn = $wpdb->get_var("SELECT payment_transaction_id FROM {$wpdb->pmpro_membership_orders} WHERE payment_transaction_id = '" . $txn_id . "' LIMIT 1"); if (empty($old_txn)) { //save order $morder = new MemberOrder(); $morder->user_id = $last_order->user_id; $morder->membership_id = $last_order->membership_id; $morder->payment_transaction_id = $txn_id; $morder->subscription_transaction_id = $last_order->subscription_transaction_id; $morder->gateway = $last_order->gateway; $morder->gateway_environment = $last_order->gateway_environment; // Payment Status $morder->status = 'success'; // We have confirmed that and thats the reason we are here. // Payment Type. $morder->payment_type = $last_order->payment_type; //set amount based on which PayPal type if (false !== stripos($last_order->gateway, "paypal")) { if (isset($_POST['amount']) && !empty($_POST['amount'])) { $morder->InitialPayment = $_POST['amount']; //not the initial payment, but the class is expecting that $morder->PaymentAmount = $_POST['amount']; } elseif (isset($_POST['mc_gross']) && !empty($_POST['mc_gross'])) { $morder->InitialPayment = $_POST['mc_gross']; //not the initial payment, but the class is expecting that $morder->PaymentAmount = $_POST['mc_gross']; } elseif (isset($_POST['payment_gross']) && !empty($_POST['payment_gross'])) { $morder->InitialPayment = $_POST['payment_gross']; //not the initial payment, but the class is expecting that $morder->PaymentAmount = $_POST['payment_gross']; } } $morder->FirstName = $_POST['first_name']; $morder->LastName = $_POST['last_name']; $morder->Email = $_POST['payer_email']; //get address info if appropriate if ($last_order->gateway == "paypal") { $morder->Address1 = get_user_meta($last_order->user_id, "pmpro_baddress1", true); $morder->City = get_user_meta($last_order->user_id, "pmpro_bcity", true); $morder->State = get_user_meta($last_order->user_id, "pmpro_bstate", true); $morder->CountryCode = "US"; $morder->Zip = get_user_meta($last_order->user_id, "pmpro_bzip", true); $morder->PhoneNumber = get_user_meta($last_order->user_id, "pmpro_bphone", true); $morder->billing->name = $_POST['first_name'] . " " . $_POST['last_name']; $morder->billing->street = get_user_meta($last_order->user_id, "pmpro_baddress1", true); $morder->billing->city = get_user_meta($last_order->user_id, "pmpro_bcity", true); $morder->billing->state = get_user_meta($last_order->user_id, "pmpro_bstate", true); $morder->billing->zip = get_user_meta($last_order->user_id, "pmpro_bzip", true); $morder->billing->country = get_user_meta($last_order->user_id, "pmpro_bcountry", true); $morder->billing->phone = get_user_meta($last_order->user_id, "pmpro_bphone", true); //get CC info that is on file $morder->cardtype = get_user_meta($last_order->user_id, "pmpro_CardType", true); $morder->accountnumber = hideCardNumber(get_user_meta($last_order->user_id, "pmpro_AccountNumber", true), false); $morder->expirationmonth = get_user_meta($last_order->user_id, "pmpro_ExpirationMonth", true); $morder->expirationyear = get_user_meta($last_order->user_id, "pmpro_ExpirationYear", true); $morder->ExpirationDate = $morder->expirationmonth . $morder->expirationyear; $morder->ExpirationDate_YdashM = $morder->expirationyear . "-" . $morder->expirationmonth; } //figure out timestamp or default to none (today) if (!empty($_POST['payment_date'])) { $morder->timestamp = strtotime($_POST['payment_date']); } // Save the event ID for the last processed user/IPN (in case we want to be able to replay IPN requests) $ipn_id = isset($_POST['ipn_track_id']) ? sanitize_text_field($_POST['ipn_track_id']) : null; // Allow extraction of the IPN Track ID from the order notes (if needed) $morder->notes = "{$morder->notes} [IPN_ID]{$ipn_id}[/IPN_ID]"; /** * Post processing for a specific subscription related IPN event ID * * @param string $ipn_id - The ipn_track_id from the PayPal IPN request * @param MemberOrder $morder - The completed Member Order object for the IPN request */ do_action('pmpro_subscription_ipn_event_processed', $ipn_id, $morder); if (!is_null($ipn_id)) { if (false === update_user_meta($morder->user_id, "pmpro_last_{$morder->gateway}_ipn_id", $ipn_id)) { ipnlog("Unable to save the IPN event ID ({$ipn_id}) to usermeta for {$morder->user_id} "); } } //save $morder->saveOrder(); $morder->getMemberOrderByID($morder->id); //email the user their invoice $pmproemail = new PMProEmail(); $pmproemail->sendInvoiceEmail(get_userdata($last_order->user_id), $morder); //hook for successful subscription payments do_action("pmpro_subscription_payment_completed", $morder); ipnlog("New order (" . $morder->code . ") created."); return true; } else { ipnlog("Duplicate Transaction ID: " . $txn_id); return false; } }
function billing_content_func($atts) { global $wpdb, $pmpro_msg, $pmpro_msgt, $pmpro_levels, $current_user, $levels; //-> If a member is logged in, show them some info here (1. past invoices. 2. billing information with button to update.) if ($current_user->membership_level->ID) { if ($pmpro_msg) { ?> <div class="pmpro_message <?php echo $pmpro_msgt; ?> "><?php echo $pmpro_msg; ?> </div> <?php } ?> <div class="row"> <div class="col-md-8 col-sm-8 col-sm-offset-2 col-md-offset-2"> <!-- BEGIN CONTENT--> <div id="pmpro_account"> <div id="pmpro_account-membership" class="pmpro_box"> <p><?php _e("Your membership is <strong>active</strong>.", "pmpro"); ?> </p> <ul> <li><strong><?php _e("Level", "pmpro"); ?> :</strong> <?php echo $current_user->membership_level->name; ?> </li> <?php if ($current_user->membership_level->billing_amount > 0) { ?> <li><strong><?php _e("Membership Fee", "pmpro"); ?> :</strong> <?php $level = $current_user->membership_level; if ($current_user->membership_level->cycle_number > 1) { printf(__('%s every %d %s.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number)); } elseif ($current_user->membership_level->cycle_number == 1) { printf(__('%s per %s.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period)); } else { echo pmpro_formatPrice($current_user->membership_level->billing_amount); } ?> </li> <?php } ?> <?php if ($current_user->membership_level->billing_limit) { ?> <li><strong><?php _e("Duration", "pmpro"); ?> :</strong> <?php echo $current_user->membership_level->billing_limit . ' ' . sornot($current_user->membership_level->cycle_period, $current_user->membership_level->billing_limit); ?> </li> <?php } ?> <?php if ($current_user->membership_level->enddate) { ?> <li><strong><?php _e("Membership Expires", "pmpro"); ?> :</strong> <?php echo date_i18n(get_option('date_format'), $current_user->membership_level->enddate); ?> </li> <?php } ?> <?php if ($current_user->membership_level->trial_limit == 1) { printf(__("Your first payment will cost %s.", "pmpro"), pmpro_formatPrice($current_user->membership_level->trial_amount)); } elseif (!empty($current_user->membership_level->trial_limit)) { printf(__("Your first %d payments will cost %s.", "pmpro"), $current_user->membership_level->trial_limit, pmpro_formatPrice($current_user->membership_level->trial_amount)); } ?> </ul> </div> <!-- end pmpro_account-membership --> <div id="pmpro_account-profile" class="pmpro_box hide"> <?php get_currentuserinfo(); ?> <h3><?php _e("My Account", "pmpro"); ?> </h3> <?php if ($current_user->user_firstname) { ?> <p><?php echo $current_user->user_firstname; ?> <?php echo $current_user->user_lastname; ?> </p> <?php } ?> <ul> <li><strong><?php _e("Username", "pmpro"); ?> :</strong> <?php echo $current_user->user_login; ?> </li> <li><strong><?php _e("Email", "pmpro"); ?> :</strong> <?php echo $current_user->user_email; ?> </li> </ul> <p> <a href="<?php echo admin_url('profile.php'); ?> "><?php _e("Edit Profile", "pmpro"); ?> </a> | <a href="<?php echo admin_url('profile.php'); ?> "><?php _ex("Change Password", "As in 'change password'.", "pmpro"); ?> </a> </p> </div> <!-- end pmpro_account-profile --> <?php //last invoice for current info //$ssorder = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM $wpdb->pmpro_membership_orders WHERE user_id = '$current_user->ID' AND membership_id = '" . $current_user->membership_level->ID . "' AND status = 'success' ORDER BY timestamp DESC LIMIT 1"); $ssorder = new MemberOrder(); $ssorder->getLastMemberOrder(); $invoices = $wpdb->get_results("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM {$wpdb->pmpro_membership_orders} WHERE user_id = '{$current_user->ID}' ORDER BY timestamp DESC LIMIT 6"); if (!empty($ssorder->id) && $ssorder->gateway != "check" && $ssorder->gateway != "paypalexpress" && $ssorder->gateway != "paypalstandard" && $ssorder->gateway != "twocheckout") { //default values from DB (should be last order or last update) $bfirstname = get_user_meta($current_user->ID, "pmpro_bfirstname", true); $blastname = get_user_meta($current_user->ID, "pmpro_blastname", true); $baddress1 = get_user_meta($current_user->ID, "pmpro_baddress1", true); $baddress2 = get_user_meta($current_user->ID, "pmpro_baddress2", true); $bcity = get_user_meta($current_user->ID, "pmpro_bcity", true); $bstate = get_user_meta($current_user->ID, "pmpro_bstate", true); $bzipcode = get_user_meta($current_user->ID, "pmpro_bzipcode", true); $bcountry = get_user_meta($current_user->ID, "pmpro_bcountry", true); $bphone = get_user_meta($current_user->ID, "pmpro_bphone", true); $bemail = get_user_meta($current_user->ID, "pmpro_bemail", true); $bconfirmemail = get_user_meta($current_user->ID, "pmpro_bconfirmemail", true); $CardType = get_user_meta($current_user->ID, "pmpro_CardType", true); $AccountNumber = hideCardNumber(get_user_meta($current_user->ID, "pmpro_AccountNumber", true), false); $ExpirationMonth = get_user_meta($current_user->ID, "pmpro_ExpirationMonth", true); $ExpirationYear = get_user_meta($current_user->ID, "pmpro_ExpirationYear", true); ?> <div id="pmpro_account-billing" class="pmpro_box"> <h3><?php _e("Billing Information", "pmpro"); ?> </h3> <?php if (!empty($baddress1)) { ?> <p> <strong><?php _e("Billing Address", "pmpro"); ?> </strong><br /> <?php echo $bfirstname . " " . $blastname; ?> <br /> <?php echo $baddress1; ?> <br /> <?php if ($baddress2) { echo $baddress2 . "<br />"; } ?> <?php if ($bcity && $bstate) { ?> <?php echo $bcity; ?> , <?php echo $bstate; ?> <?php echo $bzipcode; ?> <?php echo $bcountry; ?> <?php } ?> <br /> <?php echo formatPhone($bphone); ?> </p> <?php } ?> <?php if (!empty($AccountNumber)) { ?> <p> <strong><?php _e("Payment Method", "pmpro"); ?> </strong><br /> <?php echo $CardType; ?> : <?php echo last4($AccountNumber); ?> (<?php echo $ExpirationMonth; ?> /<?php echo $ExpirationYear; ?> ) </p> <?php } ?> <?php if (isset($ssorder->status) && $ssorder->status == "success" && (isset($ssorder->gateway) && in_array($ssorder->gateway, array("authorizenet", "paypal", "stripe", "braintree", "payflow", "cybersource")))) { ?> <p><a href="<?php echo pmpro_url("billing", ""); ?> "><?php _e("Edit Billing Information", "pmpro"); ?> </a></p> <?php } ?> </div> <!-- end pmpro_account-billing --> <?php } ?> <?php if (!empty($invoices)) { ?> <div id="pmpro_account-invoices" class="pmpro_box"> <h3><?php _e("Past Invoices", "pmpro"); ?> </h3> <ul> <?php $count = 0; foreach ($invoices as $invoice) { if ($count++ > 5) { break; } ?> <li><a href="<?php echo pmpro_url("invoice", "?invoice=" . $invoice->code); ?> "><?php echo date_i18n(get_option("date_format"), $invoice->timestamp); ?> (<?php echo pmpro_formatPrice($invoice->total); ?> )</a></li> <?php } ?> </ul> <?php if ($count == 6) { ?> <p><a href="<?php echo pmpro_url("invoice"); ?> "><?php _e("View All Invoices", "pmpro"); ?> </a></p> <?php } ?> </div> <!-- end pmpro_account-billing --> <?php } ?> <p class="help-block">We have the following subscriptions available for our site. To join, simply click on the <strong>Renew</strong> or <strong>Change Subscription</strong> button and then complete the registration details.</p> <?php getLevels(); ?> <div id="pmpro_account-links" class="pmpro_box"> <h3><?php _e("Manage Membership", "pmpro"); ?> </h3> <ul> <?php do_action("pmpro_member_links_top"); ?> <?php if (isset($ssorder->status) && $ssorder->status == "success" && (isset($ssorder->gateway) && in_array($ssorder->gateway, array("authorizenet", "paypal", "stripe", "braintree", "payflow", "cybersource")))) { ?> <li><a href="<?php echo pmpro_url("billing", "", "https"); ?> "><?php _e("Update Billing Information", "pmpro"); ?> </a></li> <?php } ?> <?php if (count($pmpro_levels) > 1 && !defined("PMPRO_DEFAULT_LEVEL")) { ?> <li><a href="<?php echo pmpro_url("levels"); ?> "> <?php _e("Change Membership Level", "pmpro"); ?> </a></li> <?php } ?> <li><a href="<?php echo pmpro_url("cancel"); ?> " class="red"><?php _e("Cancel Membership", "pmpro"); ?> </a></li> <?php do_action("pmpro_member_links_bottom"); ?> </ul> </div> <!-- end pmpro_account-links --> </div> <!-- end pmpro_account --> <!-- END CONTENT--> </div> </div> <?php } ?> <?php }