strangerstudios / pmpro-pay-by-check

Add a "Pay by Check" option to PMPro levels, and keep members in "pending" status until an admin changes the order status.
https://www.paidmembershipspro.com/add-ons/pmpro-pay-by-check-add-on/
11 stars 27 forks source link

Too many orders being created #60

Closed dparker1005 closed 1 year ago

dparker1005 commented 3 years ago

A user had an issue on their site where a new pending order was being created on their site every day, even though the user's membership was set to renew annually. This behavior is being caused by the $combo behavior in the pmpropbc_recurring_orders() function. Each $combo is being applied to each user's membership regardless of the actual cycle period/cycle number set for that membership, meaning that users may have orders created when they should not be.

Steps to replicate:

  1. Set up a new site with PMPro Pay By Check
  2. Check out as a new user for an annually recurring membership while paying by check
  3. Run the pmpropbc_recurring_orders cron repeatedly and note how new orders are not created
  4. Give another user the same membership level and modify their membership in the DB to be recurring daily
  5. Run the pmpropbc_recurring_orders cron repeatedly and see how a new order is created for the original user on every run, even though their membership was not changed at all

Proposed change: While looping through $combos, we should amend this check to make sure that the user's membership matches the specified $combo: if( $user->membership_level->cycle_number == 0 || $user->membership_level->billing_amount == 0)

For sites actively experiencing this issue, please go into your database and search for any records in the pmpro_memberships_users table with Day as the cycle period. If there are active records that match this description, change them to inactive status if the memberships are no longer being used. If the memberships are still being used but you need this issue fixed, please reach out to our member support forum.

andrewlimaza commented 1 year ago

This can be replicated by also using the Payment Plans Add On and set it to daily as an option.

I set the recurring email reminders, cancellations inside the Pay By Check settings to 30 days as well for this particular level.