当前位置: 首页>>代码示例>>PHP>>正文


PHP MemberOrder::process方法代码示例

本文整理汇总了PHP中MemberOrder::process方法的典型用法代码示例。如果您正苦于以下问题:PHP MemberOrder::process方法的具体用法?PHP MemberOrder::process怎么用?PHP MemberOrder::process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MemberOrder的用法示例。


在下文中一共展示了MemberOrder::process方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pmpropbc_recurring_orders

function pmpropbc_recurring_orders()
{
    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['renewal_days'])) {
            $date = date("Y-m-d", strtotime("+ " . $options['renewal_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) {
            //check if it's been one pay period since the last payment
            /*
            	- Check should create an invoice X days before expiration based on a setting on the levels page.
            	- Set invoice date based on cycle and the day of the month of the member start date.
            	- Send a reminder email Y days after initial invoice is created if it's still pending.
            	- Cancel membership after Z days if invoice is not paid. Send email.
            */
            //get all check orders still pending after X days
            $sqlQuery = "\r\n\t\t\t\tSELECT o1.id FROM\r\n\t\t\t\t    (SELECT id, user_id, timestamp\r\n\t\t\t\t    FROM {$wpdb->pmpro_membership_orders}\r\n\t\t\t\t    WHERE membership_id = {$level->id}\r\n\t\t\t\t        AND gateway = 'check' \r\n\t\t\t\t        AND status IN('pending', 'success')\r\n\t\t\t\t    ) as o1\r\n\r\n\t\t\t\t\tLEFT OUTER JOIN \r\n\t\t\t\t\t\r\n\t\t\t\t\t(SELECT id, user_id, timestamp\r\n\t\t\t\t    FROM {$wpdb->pmpro_membership_orders}\r\n\t\t\t\t    WHERE membership_id = {$level->id}\r\n\t\t\t\t        AND gateway = 'check' \r\n\t\t\t\t        AND status IN('pending', 'success')\r\n\t\t\t\t    ) as o2\r\n\r\n\t\t\t\t\tON o1.user_id = o2.user_id\r\n\t\t\t\t\tAND o1.timestamp < o2.timestamp\r\n\t\t\t\t\tOR (o1.timestamp = o2.timestamp AND o1.id < o2.id)\r\n\t\t\t\tWHERE\r\n\t\t\t\t\to2.id IS NULL\r\n\t\t\t\t\tAND DATE_ADD(o1.timestamp, INTERVAL {$combo}) <= '" . $date . "'\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) {
                $order = new MemberOrder($order_id);
                $user = get_userdata($order->user_id);
                $user->membership_level = pmpro_getMembershipLevelForUser($order->user_id);
                //check that user still has same level?
                if (empty($user->membership_level) || $order->membership_id != $user->membership_level->id) {
                    continue;
                }
                //create new pending order
                $morder = new MemberOrder();
                $morder->user_id = $order->user_id;
                $morder->membership_id = $user->membership_level->id;
                $morder->InitialPayment = $user->membership_level->billing_amount;
                $morder->PaymentAmount = $user->membership_level->billing_amount;
                $morder->BillingPeriod = $user->membership_level->cycle_period;
                $morder->BillingFrequency = $user->membership_level->cycle_number;
                $morder->subscription_transaction_id = $order->subscription_transaction_id;
                $morder->gateway = "check";
                $morder->setGateway();
                $morder->payment_type = "Check";
                $morder->status = "pending";
                //get timestamp for new order
                $order_timestamp = strtotime("+" . $combo, $order->timestamp);
                //let's skip if there is already an order for this user/level/timestamp
                $sqlQuery = "SELECT id FROM {$wpdb->pmpro_membership_orders} WHERE user_id = '" . $order->user_id . "' AND membership_id = '" . $order->membership_id . "' AND timestamp = '" . date('d', $order_timestamp) . "' LIMIT 1";
                $dupe = $wpdb->get_var("SELECT id FROM {$wpdb->pmpro_membership_orders} WHERE user_id = '" . $order->user_id . "' AND membership_id = '" . $order->membership_id . "' AND timestamp = '" . $order_timestamp . "' LIMIT 1");
                if (!empty($dupe)) {
                    continue;
                }
                //save it
                $morder->process();
                $morder->saveOrder();
                //update the timestamp
                $morder->updateTimestamp(date("Y", $order_timestamp), date("m", $order_timestamp), date("d", $order_timestamp));
                //send emails
                $email = new PMProEmail();
                $email->template = "check_pending";
                $email->email = $user->user_email;
                $email->subject = sprintf(__("New Invoice for %s at %s", "pmpropbc"), $user->membership_level->name, get_option("blogname"));
            }
        }
    }
}
开发者ID:eighty20results,项目名称:pmpro-pay-by-check,代码行数:85,代码来源:pmpro-pay-by-check.php

示例2: unset

 //setup 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->process()) {
     $submit = true;
     $pmpro_confirmed = true;
     if (!$current_user->ID) {
         //reload the user fields
         $username = $_SESSION['pmpro_signup_username'];
         $password = $_SESSION['pmpro_signup_password'];
         $password2 = $password;
         $bemail = $_SESSION['pmpro_signup_email'];
         //unset the user fields in session
         unset($_SESSION['pmpro_signup_username']);
         unset($_SESSION['pmpro_signup_password']);
         unset($_SESSION['pmpro_signup_email']);
     }
 } else {
     $pmpro_msg = $morder->error;
开发者ID:danielcoats,项目名称:schoolpress,代码行数:31,代码来源:checkout.php


注:本文中的MemberOrder::process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。