Unable to load the membership plan to modify

3 replies [Last post]
isdept
Offline
Joined: 10/25/2011
Status: 
Answered

I have two Memberships set up, a Monthly and a Yearly. I have set the Modification Settings to allow users to modify their membership to change it from a Monthly to a Yearly or a Yearly to a Monthly. I'm using the CRE Secure payment gateway.

I have users who are set to a Monthly Membership who want to upgrade to a Yearly Membership. They log into their account and this is what it looks like:

Membership tab:

   Monthly Membership    Active - Recurring    Sun, 02/19/2012 - 11:00 - $9.00    None    Cancel Membership | Change Membership

Order history tab:

   101    Sat, 09/17/2011 - 15:15    Monthly Membership    Active    $$$$$    View Details

So then they go to the Membership tab and click "Change Membership." On the "Change Membership" page they choose the "Yearly Membership" level and click "Submit." Then they receive an "Are you sure you want to change your order to Yearly Membership?" and they click "Confirm." At the conclusion, they are redirected back to the home page.

In the log reports, I see that the payment was successfully processed by ms_cres and ms_core! However, ms_memberships was unable to modify the membership. The following error is given:

  1. Unable to load the membership plan to modify. Product:
  2. MsProduct Object
  3. (
  4.     [order_product_id] => 2518
  5.     [oid] => 101
  6.     [type] => recurring
  7.     [name] => Yearly Membership
  8.     [module] => ms_membership
  9.     [qty] => 1
  10.     [amount] => 99.00000
  11.     [id] => 3
  12.     [data] => Array
  13.         (
  14.             [override_settings] => Array
  15.                 (
  16.                     [ms_core_payment_reminder_days] => 7
  17.                 )
  18.  
  19.         )
  20.     [recurring_schedule] => Array
  21.         (
  22.             [total_occurrences] => 0
  23.             [main_amount] => 99.00
  24.             [main_length] => 1
  25.             [main_unit] => Y
  26.             [has_trial] =>
  27.             [trial_amount] => 0.00
  28.             [trial_length] => 0
  29.             [trial_unit] => D
  30.         )
  31. )
  32. Logged at /home/www/drupal/sites/all/modules/ms_membership/ms_membership.module line 3223

They visit their Account pages and this is what it looks like now:

Membership tab:

   Monthly Membership    Active - Recurring    Thu, 01/24/2013 - 12:14 - $99.00    None    Cancel Membership | Change Membership

Order history tab:

   101    Sat, 09/17/2011 - 15:15    Yearly Membership    Active    $$$$$    View Details

So everything worked correctly on the financial side, but the Membership on the Membership tab was not successfully changed from "Monthly Membership" to "Yearly Membership".

isdept
Offline
Joined: 10/25/2011
Hey Leighton!The inability

Hey Leighton!

The inability for ms_memberships to change a membership plan as described above is probably related to this piece of code in ms_memberships.module:

  1. if (isset($product->data['modify_mid']) AND $old_membership = ms_membership_load_membership($product->data['modify_mid'])) {
  2.   ms_membership_modify_membership($order, $old_membership, $m_plan);
  3. }
  4. else {
  5.   ms_core_log_error('ms_membership', 'Unable to load the membership plan to modify. Product: !product',
  6.   array('!product' => ms_core_print_r($product)), WATCHDOG_ERROR);
  7. }
  8. break;

Somehow "modify_mid" isn't getting properly set...

Leighton Whiting
Offline
Joined: 06/02/2009
I believe this is because CRE

I believe this is because CRE Secure modifies the recurring order directly, rather than making a new one.

Adding an extra else if clause to ms_membership.module should fix it:

  1. case "rec_modify":
  2.             if (isset($product->data['modify_mid']) AND $old_membership = ms_membership_load_membership($product->data['modify_mid'])) {
  3.               ms_membership_modify_membership($order, $old_membership, $m_plan);
  4.             }
  5.             else if (isset($order->data['new_product']) AND $old_membership = ms_membership_load_membership_order_id($order->oid)) {
  6.               ms_membership_modify_membership($order, $old_membership, $m_plan);
  7.             }
  8.             else {
  9.               ms_core_log_error('ms_membership', 'Unable to load the membership plan to modify. Product: !product',
  10.                array('!product' => ms_core_print_r($product)), WATCHDOG_ERROR);
  11.             }
  12.             break;

isdept
Offline
Joined: 10/25/2011
This solution worked

This solution worked beautifully! Thank you!

Twitter Feed