function pmpro_shortcode_account($atts, $content = null, $code = "") { global $wpdb, $pmpro_msg, $pmpro_msgt, $pmpro_levels, $current_user, $levels; // $atts ::= array of attributes // $content ::= text within enclosing form of shortcode element // $code ::= the shortcode found, when == callback name // examples: [pmpro_account] [pmpro_account sections="membership,profile"/] extract(shortcode_atts(array('section' => '', 'sections' => 'membership,profile,invoices,links'), $atts)); //did they use 'section' instead of 'sections'? if (!empty($section)) { $sections = $section; } //turn into an array $sections = explode(',', $sections); ob_start(); //if a member is logged in, show them some info here (1. past invoices. 2. billing information with button to update.) if (pmpro_hasMembershipLevel()) { $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"); ?> <div id="pmpro_account"> <?php if (in_array('membership', $sections) || in_array('memberships', $sections)) { ?> <div id="pmpro_account-membership" class="pmpro_box"> <h3><?php _e("My Memberships", "pmpro"); ?> </h3> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th><?php _e("Level", "pmpro"); ?> </th> <th><?php _e("Billing", "pmpro"); ?> </th> <th><?php _e("Expiration", "pmpro"); ?> </th> </tr> </thead> <tbody> <?php //TODO: v2.0 will loop through levels here $level = $current_user->membership_level; ?> <tr> <td class="pmpro_account-membership-levelname"> <?php echo $current_user->membership_level->name; ?> <div class="pmpro_actionlinks"> <?php do_action("pmpro_member_action_links_before"); ?> <?php if (pmpro_isLevelExpiringSoon($current_user->membership_level)) { ?> <a href="<?php echo pmpro_url("checkout", "?level=" . $current_user->membership_level->id, "https"); ?> "><?php _e("Renew", "pmpro"); ?> </a> <?php } ?> <?php if (isset($ssorder->status) && $ssorder->status == "success" && (isset($ssorder->gateway) && in_array($ssorder->gateway, array("authorizenet", "paypal", "stripe", "braintree", "payflow", "cybersource")))) { ?> <a href="<?php echo pmpro_url("billing", "", "https"); ?> "><?php _e("Update Billing Info", "pmpro"); ?> </a> <?php } ?> <?php //To do: Only show CHANGE link if this level is in a group that has upgrade/downgrade rules if (count($pmpro_levels) > 1 && !defined("PMPRO_DEFAULT_LEVEL")) { ?> <a href="<?php echo pmpro_url("levels"); ?> "><?php _e("Change", "pmpro"); ?> </a> <?php } ?> <a href="<?php echo pmpro_url("cancel", "?level=" . $current_user->membership_level->id); ?> "><?php _e("Cancel", "pmpro"); ?> </a> <?php do_action("pmpro_member_action_links_after"); ?> </div> <!-- end pmpro_actionlinks --> </td> <td class="pmpro_account-membership-levelfee"> <p><?php echo pmpro_getLevelCost($level, true, true); ?> </p> </td> <td class="pmpro_account-membership-expiration"> <?php if ($current_user->membership_level->enddate) { echo date(get_option('date_format'), $current_user->membership_level->enddate); } else { echo "---"; } ?> </td> </tr> </tbody> </table> <?php //Todo: If there are multiple levels defined that aren't all in the same group defined as upgrades/downgrades ?> <div class="pmpro_actionlinks"> <a href="<?php echo pmpro_url("levels"); ?> "><?php _e("View all Membership Options", "pmpro"); ?> </a> </div> </div> <!-- end pmpro_account-membership --> <?php } ?> <?php if (in_array('profile', $sections)) { ?> <div id="pmpro_account-profile" class="pmpro_box"> <?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> <?php do_action('pmpro_account_bullets_top'); ?> <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> <?php do_action('pmpro_account_bullets_bottom'); ?> </ul> <div class="pmpro_actionlinks"> <a href="<?php echo admin_url('profile.php'); ?> "><?php _e("Edit Profile", "pmpro"); ?> </a> <a href="<?php echo admin_url('profile.php'); ?> "><?php _e('Change Password', 'pmpro'); ?> </a> </div> </div> <!-- end pmpro_account-profile --> <?php } ?> <?php if (in_array('invoices', $sections) && !empty($invoices)) { ?> <div id="pmpro_account-invoices" class="pmpro_box"> <h3><?php _e("Past Invoices", "pmpro"); ?> </h3> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th><?php _e("Date", "pmpro"); ?> </th> <th><?php _e("Level", "pmpro"); ?> </th> <th><?php _e("Amount", "pmpro"); ?> </th> </tr> </thead> <tbody> <?php $count = 0; foreach ($invoices as $invoice) { if ($count++ > 4) { break; } //get an member order object $invoice_id = $invoice->id; $invoice = new MemberOrder(); $invoice->getMemberOrderByID($invoice_id); $invoice->getMembershipLevel(); ?> <tr id="pmpro_account-invoice-<?php echo $invoice->code; ?> "> <td><a href="<?php echo pmpro_url("invoice", "?invoice=" . $invoice->code); ?> "><?php echo date(get_option("date_format"), $invoice->timestamp); ?> </td> <td><?php echo $invoice->membership_level->name; ?> </td> <td><?php echo pmpro_formatPrice($invoice->total); ?> </td> </tr> <?php } ?> </tbody> </table> <?php if ($count == 6) { ?> <div class="pmpro_actionlinks"><a href="<?php echo pmpro_url("invoice"); ?> "><?php _e("View All Invoices", "pmpro"); ?> </a></div> <?php } ?> </div> <!-- end pmpro_account-invoices --> <?php } ?> <?php if (in_array('links', $sections) && (has_filter('pmpro_member_links_top') || has_filter('pmpro_member_links_bottom'))) { ?> <div id="pmpro_account-links" class="pmpro_box"> <h3><?php _e("Member Links", "pmpro"); ?> </h3> <ul> <?php do_action("pmpro_member_links_top"); ?> <?php do_action("pmpro_member_links_bottom"); ?> </ul> </div> <!-- end pmpro_account-links --> <?php } ?> </div> <!-- end pmpro_account --> <?php } $content = ob_get_contents(); ob_end_clean(); return $content; }
/** * Review and Confirmation code. * * @since 1.8 */ static function pmpro_checkout_confirmed($pmpro_confirmed) { global $pmpro_msg, $pmpro_msgt, $pmpro_level, $current_user, $pmpro_review, $pmpro_paypal_token, $discount_code, $bemail; //PayPal Express Call Backs if (!empty($_REQUEST['review'])) { if (!empty($_REQUEST['PayerID'])) { $_SESSION['payer_id'] = $_REQUEST['PayerID']; } if (!empty($_REQUEST['paymentAmount'])) { $_SESSION['paymentAmount'] = $_REQUEST['paymentAmount']; } if (!empty($_REQUEST['currencyCodeType'])) { $_SESSION['currCodeType'] = $_REQUEST['currencyCodeType']; } if (!empty($_REQUEST['paymentType'])) { $_SESSION['paymentType'] = $_REQUEST['paymentType']; } $morder = new MemberOrder(); $morder->getMemberOrderByPayPalToken($_REQUEST['token']); $morder->Token = $morder->paypal_token; $pmpro_paypal_token = $morder->paypal_token; if ($morder->Token) { if ($morder->Gateway->getExpressCheckoutDetails($morder)) { $pmpro_review = true; } else { $pmpro_msg = $morder->error; $pmpro_msgt = "pmpro_error"; } } else { $pmpro_msg = __("The PayPal Token was lost.", "pmpro"); $pmpro_msgt = "pmpro_error"; } } elseif (!empty($_REQUEST['confirm'])) { $morder = new MemberOrder(); $morder->getMemberOrderByPayPalToken($_REQUEST['token']); $morder->Token = $morder->paypal_token; $pmpro_paypal_token = $morder->paypal_token; if ($morder->Token) { //set up values $morder->membership_id = $pmpro_level->id; $morder->membership_name = $pmpro_level->name; $morder->discount_code = $discount_code; $morder->InitialPayment = $pmpro_level->initial_payment; $morder->PaymentAmount = $pmpro_level->billing_amount; $morder->ProfileStartDate = date("Y-m-d") . "T0:0:0"; $morder->BillingPeriod = $pmpro_level->cycle_period; $morder->BillingFrequency = $pmpro_level->cycle_number; $morder->Email = $bemail; //set up level var $morder->getMembershipLevel(); $morder->membership_level = apply_filters("pmpro_checkout_level", $morder->membership_level); //tax $morder->subtotal = $morder->InitialPayment; $morder->getTax(); if ($pmpro_level->billing_limit) { $morder->TotalBillingCycles = $pmpro_level->billing_limit; } if (pmpro_isLevelTrial($pmpro_level)) { $morder->TrialBillingPeriod = $pmpro_level->cycle_period; $morder->TrialBillingFrequency = $pmpro_level->cycle_number; $morder->TrialBillingCycles = $pmpro_level->trial_limit; $morder->TrialAmount = $pmpro_level->trial_amount; } if ($morder->confirm()) { $pmpro_confirmed = true; } else { $pmpro_msg = $morder->error; $pmpro_msgt = "pmpro_error"; } } else { $pmpro_msg = __("The PayPal Token was lost.", "pmpro"); $pmpro_msgt = "pmpro_error"; } } if (!empty($morder)) { return array("pmpro_confirmed" => $pmpro_confirmed, "morder" => $morder); } else { return $pmpro_confirmed; } }
//update membership if (pmpro_insChangeMembershipLevel($txn_id, $morder)) { inslog("Checkout processed (" . $morder->code . ") success!"); } else { inslog("ERROR: Couldn't change level for order (" . $morder->code . ")."); } pmpro_twocheckoutExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id)); } // Recurring Payment Success (recurring installment success and recurring is true) if ($message_type == 'RECURRING_INSTALLMENT_SUCCESS') { //is this a first payment? $last_subscr_order = new MemberOrder(); if ($last_subscr_order->getLastMemberOrderBySubscriptionTransactionID($txn_id) == false) { //first payment, get order $morder = new MemberOrder($order_id); $morder->getMembershipLevel(); $morder->getUser(); //update membership if (pmpro_insChangeMembershipLevel($txn_id, $morder)) { inslog("Checkout processed (" . $morder->code . ") success!"); } else { inslog("ERROR: Couldn't change level for order (" . $morder->code . ")."); } } else { pmpro_insSaveOrder($txn_id, $last_subscr_order); } pmpro_twocheckoutExit(); } // Recurring Payment Failed (recurring installment failed and recurring is true) if ($message_type == 'RECURRING_INSTALLMENT_FAILED' && $recurring) { //is this a first payment?
if (!empty($extra_columns)) { foreach ($extra_columns as $heading => $callback) { $csvoutput .= "," . $heading; } } $csvoutput .= "\n"; //output echo $csvoutput; $csvoutput = ""; if ($order_ids) { foreach ($order_ids as $order_id) { $order = new MemberOrder(); $order->nogateway = true; $order->getMemberOrderByID($order_id); $user = get_userdata($order->user_id); $level = $order->getMembershipLevel(); $sqlQuery = "SELECT c.id, c.code FROM {$wpdb->pmpro_discount_codes_uses} cu LEFT JOIN {$wpdb->pmpro_discount_codes} c ON cu.code_id = c.id WHERE cu.order_id = '" . $order_id . "' LIMIT 1"; $discount_code = $wpdb->get_row($sqlQuery); //default columns if (!empty($default_columns)) { $count = 0; foreach ($default_columns as $col) { //add comma after the first item $count++; if ($count > 1) { $csvoutput .= ","; } //checking $object->property. note the double $$ if (!empty($col[2]) && isset(${$col}[0]->{$col}[1]->{$col}[2])) { $csvoutput .= pmpro_enclose(${$col}[0]->{$col}[1]->{$col}[2]); } elseif (!empty(${$col}[0]->{$col}[1])) {
<div class="row"> <div class="col-md-4"><h6>Date</h6></div> <div class="col-md-4"><h6>Level</h6></div> <div class="col-md-4"><h6>Amount</h6></div> </div> <?php $count = 0; foreach ($invoices as $invoice) { ?> <div class="row"> <?php //get an member order object $invoice_id = $invoice->id; $invoice = new MemberOrder(); $invoice->getMemberOrderByID($invoice_id); $invoice->getMembershipLevel(); ?> <div class="col-md-4"> <a href="<?php echo pmpro_url("invoice", "?invoice=" . $invoice->code); ?> "><?php echo date(get_option("date_format"), $invoice->timestamp); ?> </a> </div> <div class="col-md-4"> <?php echo $invoice->membership_level->name; ?> </div>
function pmpro_affiliates_no_order_checkout($user_id) { global $pmpro_affiliates_saved_order; //if an order was added, we're good already if ($pmpro_affiliates_saved_order) { return; } //get some info $user = get_userdata($user_id); $pmpro_level = pmpro_getMembershipLevelForUser($user_id); //setup an order $morder = new MemberOrder(); $morder->membership_id = $pmpro_level->id; $morder->membership_name = $pmpro_level->name; $morder->InitialPayment = 0; $morder->user_id = $user_id; $morder->Email = $user->user_email; $morder->gateway = "check"; $morder->Gateway = NULL; $morder->getMembershipLevel(); //now pass through the function above return pmpro_affiliates_pmpro_added_order($morder, true); //will create an order if there is an affiliate id }