本文整理汇总了PHP中MemberOrder::updateTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP MemberOrder::updateTimestamp方法的具体用法?PHP MemberOrder::updateTimestamp怎么用?PHP MemberOrder::updateTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberOrder
的用法示例。
在下文中一共展示了MemberOrder::updateTimestamp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stripslashes
$order->notes = stripslashes($_POST['notes']);
}
//affiliate stuff
$affiliates = apply_filters("pmpro_orders_show_affiliate_ids", false);
if (!empty($affiliates)) {
if (!in_array("affiliate_id", $read_only_fields)) {
$order->affiliate_id = $_POST['affiliate_id'];
}
if (!in_array("affiliate_subid", $read_only_fields)) {
$order->affiliate_subid = $_POST['affiliate_subid'];
}
}
//save
if ($order->saveOrder() !== false) {
//handle timestamp
if ($order->updateTimestamp($_POST['ts_year'], $_POST['ts_month'], $_POST['ts_day']) !== false) {
$pmpro_msg = __("Order saved successfully.", "pmpro");
$pmpro_msgt = "success";
} else {
$pmpro_msg = __("Error updating order timestamp.", "pmpro");
$pmpro_msgt = "error";
}
} else {
$pmpro_msg = __("Error saving order.", "pmpro");
$pmpro_msgt = "error";
}
} else {
//order passed?
if (!empty($_REQUEST['order'])) {
$order_id = intval($_REQUEST['order']);
if ($order_id > 0) {
示例2: 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"));
}
}
}
}