本文整理汇总了PHP中MS_Model_Membership::is_valid_membership方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Model_Membership::is_valid_membership方法的具体用法?PHP MS_Model_Membership::is_valid_membership怎么用?PHP MS_Model_Membership::is_valid_membership使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS_Model_Membership
的用法示例。
在下文中一共展示了MS_Model_Membership::is_valid_membership方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: column_membership
public function column_membership($item)
{
$html = '';
$is_any = true;
foreach ($item->membership_id as $id) {
if (MS_Model_Membership::is_valid_membership($id)) {
$is_any = false;
$membership = MS_Factory::load('MS_Model_Membership', $id);
$html .= sprintf('<span class="ms-bold">%s</span><br />', $membership->name);
}
}
if ($is_any) {
$html = sprintf('<span class="ms-low">%s</span>', __('Any', 'membership2'));
}
return $html;
}
示例2: __set
/**
* Set specific property.
*
* @since 1.0.0
*
* @param string $property The name of a property to associate.
* @param mixed $value The value of a property.
*/
public function __set($property, $value)
{
if (property_exists($this, $property)) {
switch ($property) {
case 'code':
$value = sanitize_text_field(preg_replace('/[^a-zA-Z0-9\\s]/', '', $value));
$this->{$property} = strtoupper($value);
$this->name = $this->{$property};
break;
case 'discount':
$this->{$property} = floatval($value);
break;
case 'discount_type':
if (self::is_valid_discount_type($value)) {
$this->{$property} = $value;
}
break;
case 'start_date':
$this->{$property} = $this->validate_date($value);
break;
case 'expire_date':
$this->{$property} = $this->validate_date($value);
if (strtotime($this->{$property}) < strtotime($this->start_date)) {
$this->{$property} = null;
}
break;
case 'membership_id':
$value = lib3()->array->get($value);
foreach ($value as $ind => $id) {
if (!MS_Model_Membership::is_valid_membership($id)) {
unset($value[$ind]);
}
}
if (empty($value)) {
$this->{$property} = array(0);
} else {
$this->{$property} = array_values($value);
}
break;
case 'max_uses':
case 'used':
$this->{$property} = absint($value);
break;
default:
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
break;
}
}
do_action('ms_addon_coupon_model__set_after', $property, $value, $this);
}
示例3: get_signup_step
/**
* Get signup process step (multi step form).
*
* @since 1.0.0
*
* @return string The current signup step after validation.
*/
private function get_signup_step()
{
static $Valid_Steps = null;
static $Login_Steps = null;
if (empty($Valid_Steps)) {
$Valid_Steps = apply_filters('ms_controller_frontend_signup_steps', array(self::STEP_CHOOSE_MEMBERSHIP, self::STEP_REGISTER_FORM, self::STEP_REGISTER_FORM_ALT, self::STEP_REGISTER_SUBMIT, self::STEP_PAYMENT_TABLE, self::STEP_GATEWAY_FORM, self::STEP_PROCESS_PURCHASE));
// These steps are only available to logged-in users.
$Login_Steps = apply_filters('ms_controller_frontend_signup_steps_private', array(self::STEP_PAYMENT_TABLE, self::STEP_GATEWAY_FORM, self::STEP_PROCESS_PURCHASE));
}
lib2()->array->equip_request('step', 'membership_id');
if (in_array($_REQUEST['step'], $Valid_Steps)) {
$step = $_REQUEST['step'];
} else {
// Initial step
$step = self::STEP_CHOOSE_MEMBERSHIP;
}
if (self::STEP_PAYMENT_TABLE == $step) {
if (!MS_Model_Membership::is_valid_membership($_REQUEST['membership_id'])) {
$step = self::STEP_CHOOSE_MEMBERSHIP;
}
}
if (self::STEP_CHOOSE_MEMBERSHIP == $step && !empty($_GET['membership_id'])) {
$step = self::STEP_PAYMENT_TABLE;
}
if (!MS_Model_Member::is_logged_in() && in_array($step, $Login_Steps)) {
$step = self::STEP_REGISTER_FORM_ALT;
}
return apply_filters('ms_controller_frontend_get_signup_step', $step, $this);
}
示例4: add_membership
/**
* Add a new membership.
*
* If multiple membership is disabled, may move existing membership.
*
* Only add a membership if a user is not already a member.
*
* @since 1.0.0
* @api
*
* @param int $membership_id The membership id to add to.
* @param string $gateway_id Optional. The gateway used to add the membership.
* @param int|string $move_from_id Optional. The membership id(s) to cancel.
*
* @return object|null $subscription
*/
public function add_membership($membership_id, $gateway_id = 'admin', $move_from_id = 0)
{
$subscription = null;
if (MS_Model_Membership::is_valid_membership($membership_id)) {
if (!$this->get_subscription($membership_id)) {
$subscription = MS_Model_Relationship::create_ms_relationship($membership_id, $this->id, $gateway_id, $move_from_id);
if ('admin' != $gateway_id) {
$subscription->get_current_invoice();
}
if (MS_Model_Relationship::STATUS_PENDING !== $subscription->status) {
$this->subscriptions[] = $subscription;
usort($this->subscriptions, array('MS_Model_Relationship', 'sort_by_priority'));
}
} else {
$subscription = $this->get_subscription($membership_id);
}
// Reset the status and start/expire dates when added by admin.
if ('admin' == $gateway_id) {
$subscription->start_date = null;
// Will calculate correct date.
$subscription->trial_expire_date = null;
$subscription->expire_date = null;
$subscription->status = MS_Model_Relationship::STATUS_ACTIVE;
$subscription->save();
$this->is_member = true;
}
}
return apply_filters('ms_model_member_add_membership', $subscription, $membership_id, $gateway_id, $move_from_id, $this);
}
示例5: create_ms_relationship
/**
* Create a new membership relationship.
*
* Search for existing relationship (unique object), creating if not exists.
* Set initial status.
*
* @since 1.0.0
* @internal
*
* @param int $membership_id The Membership to subscribe to.
* @param int $user_id The user who subscribes to the membership.
* @param string $gateway_id The gateway which is used for payment.
* @param int|string $move_from_id A list of membership IDs to cancel on
* payment. This property is handled by the MS_Model_Invoice class.
* @return MS_Model_Relationship The created relationship.
*/
public static function create_ms_relationship($membership_id = 0, $user_id = 0, $gateway_id = 'admin', $move_from_id = 0)
{
do_action('ms_model_relationship_create_ms_relationship_before', $membership_id, $user_id, $gateway_id, $move_from_id);
if (MS_Model_Membership::is_valid_membership($membership_id)) {
$subscription = self::_create_ms_relationship($membership_id, $user_id, $gateway_id, $move_from_id);
} else {
$subscription = null;
MS_Helper_Debug::log('Invalid membership_id: ' . "{$membership_id}, ms_relationship not created for {$user_id}, {$gateway_id}, {$move_from_id}");
MS_Helper_Debug::debug_trace();
}
return apply_filters('ms_model_relationship_create_ms_relationship', $subscription, $membership_id, $user_id, $gateway_id, $move_from_id);
}
示例6: create_invoice
/**
* Create invoice.
*
* Create a new invoice using the membership information.
*
* @since 1.0.0
*
* @param MS_Model_Relationship $subscription The membership to create invoice for.
* @param int $invoice_number Optional. The invoice number.
*
* @return object $invoice
*/
public static function create_invoice($subscription, $invoice_number = false)
{
$membership = $subscription->get_membership();
if (!MS_Model_Membership::is_valid_membership($membership->id)) {
throw new Exception('Invalid Membership.');
}
$invoice = null;
$member = MS_Factory::load('MS_Model_Member', $subscription->user_id);
$invoice_status = self::STATUS_NEW;
$notes = null;
if (empty($invoice_number)) {
$invoice_number = $subscription->current_invoice_number;
}
$invoice = self::get_invoice($subscription->id, $invoice_number);
// No existing invoice, create a new one.
if (!$invoice || !$invoice->id) {
$invoice = MS_Factory::create('MS_Model_Invoice');
$invoice = apply_filters('ms_model_invoice', $invoice);
}
// Update invoice info.
$invoice->ms_relationship_id = $subscription->id;
$invoice->gateway_id = $subscription->gateway_id;
$invoice->status = $invoice_status;
$invoice->invoice_date = MS_Helper_Period::current_date();
$invoice->membership_id = $membership->id;
$invoice->currency = MS_Plugin::instance()->settings->currency;
$invoice->user_id = $member->id;
$invoice->name = apply_filters('ms_model_invoice_name', sprintf(__('Invoice for %s - %s', MS_TEXT_DOMAIN), $membership->name, $member->username));
$invoice->invoice_number = $invoice_number;
$invoice->discount = 0;
$invoice->notes = $notes;
$invoice->amount = $membership->price;
// Without taxes!
// Check for trial period in the first period.
if ($subscription->is_trial_eligible() && $invoice_number === $subscription->current_invoice_number) {
$invoice->trial_price = $membership->trial_price;
// Without taxes!
$invoice->uses_trial = true;
$invoice->trial_ends = $subscription->trial_expire_date;
}
$invoice->set_due_date();
$invoice = apply_filters('ms_model_invoice_create_before_save', $invoice, $subscription);
$invoice->save();
// Refresh the tax-rate and payment description.
$invoice->total_amount_changed();
$invoice->save();
return apply_filters('ms_model_relationship_create_invoice', $invoice, $subscription, $invoice_number);
}
示例7: __set
/**
* Validate specific property before set.
*
* @since 1.0.0
*
* @param string $name The name of a property to associate.
* @param mixed $value The value of a property.
*/
public function __set($property, $value)
{
if (property_exists($this, $property)) {
switch ($property) {
case 'membership_id':
$this->membership_id = null;
$id = absint($value);
if (!empty($id)) {
if (MS_Model_Membership::is_valid_membership($id)) {
$this->membership_id = $id;
$this->needs_datepicker();
}
}
break;
case 'date':
if ($date = $this->validate_date($value)) {
$this->date = $value;
}
break;
default:
$this->{$property} = $value;
break;
}
}
do_action('ms_model_simulate__set_after', $property, $value, $this);
}