function transition_through_subscription()
 {
     do_action('membership_start_transition', $this->ID);
     $relationships = $this->get_relationships();
     if ($relationships) {
         foreach ($relationships as $key => $rel) {
             // Add 6 hours to the expiry date to give a grace period?
             if (strtotime("+ 6 hours", mysql2date("U", $rel->expirydate)) <= time()) {
                 // expired, we need to remove the subscription
                 if ($this->is_marked_for_expire($rel->sub_id)) {
                     $this->expire_subscription($rel->sub_id);
                     delete_user_meta($this->ID, '_membership_expire_next');
                     continue;
                 }
                 // Need to check if we are on a solo payment and have a valid payment or the next level is free.
                 $onsolo = get_user_meta($user_id, 'membership_signup_gateway_is_single', true);
                 if (!empty($onsolo) && $onsolo == 'yes') {
                     // We are on a solo gateway so need some extra checks
                     // Grab the subscription
                     $subscription = new M_Subscription($rel->sub_id);
                     // Get the next level we will be moving onto
                     $nextlevel = $subscription->get_next_level($rel->level_id, $rel->order_instance);
                     if ($nextlevel) {
                         // We have a level to move to - let's check it
                         if (empty($nextlevel->level_price) || $nextlevel->level_price == 0) {
                             // The next level is a free one, so I guess we just move to it
                             $this->move_to($rel->sub_id, $rel->level_id, $rel->order_instance, $nextlevel);
                         } else {
                             // The next level is a charged one so we need to make sure we have a payment
                             if ($this->has_active_payment($rel->sub_id, $nextlevel->level_id, $nextlevel->level_order)) {
                                 // We have a current payment for the level we are going to move to
                                 $this->move_to($rel->sub_id, $rel->level_id, $rel->order_instance, $nextlevel);
                             } else {
                                 // We don't have a payment for this next level so we have to expire it.
                                 $this->expire_subscription($rel->sub_id);
                             }
                         }
                     } else {
                         // We're at the end so need to expire this subscription
                         $this->expire_subscription($rel->sub_id);
                     }
                 } else {
                     $subscription = new M_Subscription($rel->sub_id);
                     $nextlevel = $subscription->get_next_level($rel->level_id, $rel->order_instance);
                     if ($nextlevel) {
                         if (empty($nextlevel->level_price)) {
                             // this is a non paid level transition so we can go head
                             $this->move_to($rel->sub_id, $rel->level_id, $rel->order_instance, $nextlevel);
                         } else {
                             // This is a paid level transition so check for a payment
                             // Transition for now cos we are disabling everything when a payment fails
                             $this->move_to($rel->sub_id, $rel->level_id, $rel->order_instance, $nextlevel);
                         }
                     } else {
                         // there isn't a next level so expire this subscription
                         $this->expire_subscription($rel->sub_id);
                     }
                 }
             } else {
                 // not expired we can ignore this for now
                 continue;
             }
         }
     }
     do_action('membership_end_transition', $this->ID);
 }
示例#2
0
                    $gateway = $_POST['gateway'];
                    if (nxt_verify_nonce($_REQUEST['_nxtnonce'], 'upgrade-sub_' . $sub_id) && $user == $member->ID) {
                        // Join the new subscription
                        $member->create_subscription($sub_id, $gateway);
                        // Remove the old subscription
                        $member->drop_subscription($fromsub_id);
                        // Timestamp the update
                        update_user_meta($user, '_membership_last_upgraded', time());
                    }
                    break;
            }
        }
        $rels = $member->get_relationships();
        foreach ((array) $rels as $rel) {
            $sub = new M_Subscription($rel->sub_id);
            $nextlevel = $sub->get_next_level($rel->level_id, $rel->order_instance);
            if (!empty($rel->usinggateway) && $rel->usinggateway != 'admin') {
                $gateway = M_get_class_for_gateway($rel->usinggateway);
                if (!empty($gateway) && $gateway->issingle) {
                    $gatewayissingle = 'yes';
                } else {
                    $gatewayissingle = 'no';
                }
            } else {
                $gatewayissingle = 'admin';
            }
            ?>
					<div class="renew-form">
						<div class="formleft">
							<p>
							<?php