strangerstudios / pmpro-sponsored-members

Generate a discount code for a main account holder to distribute to sponsored members.
https://www.paidmembershipspro.com/add-ons/pmpro-sponsored-members/
15 stars 27 forks source link

Allow account creation during checkout for fixed-seat configs #80

Closed gausam closed 3 years ago

gausam commented 4 years ago

Allow configurations where the number of seats is fixed and cannot be edited by the user during checkout.

All Submissions:

How to test the changes in this Pull Request:

  1. Use a fixed-seat config such as
global $pmprosm_sponsored_account_levels;
$pmprosm_sponsored_account_levels = array(
    2 => array(
        'main_level_id' => 2,
        'sponsored_level_id' => array(1),
        'min_seats' => 5,
        'max_seats' => 5,
        'seats' => 5,
        'seat_cost' => 0,
        'sponsored_accounts_at_checkout'  => true,
    )
);
  1. Visit the checkout page for the level
  2. You should be able to create 5 test accounts and the box to edit the number of accounts will not be displayed

Other information:

Changelog entry

Allow account creation during checkout for fixed-seat configs

andrewlimaza commented 4 years ago

Thanks for this, please can you test renewals for 'parent' accounts. The fields should be hidden by default and then shown if the user unchecks the 'keep child account active' or it should show the number of fields for the remaining amount of uses for that level. So if they've used 2/3, show one field. If they uncheck a child account, it should show 2 fields (1/3 'uses')

Here's my setup used for this test: global $pmprosm_sponsored_account_levels; $pmprosm_sponsored_account_levels = array( //seats based on field at checkout 1 => array( 'main_level_id' => 1, 'sponsored_level_id' => 2, 'seats' => 2, 'seat_cost' => 10, 'sponsored_accounts_at_checkout' => true, ) );

Screenshot: sponsor local_membership-account_membership-checkout__level=1

andrewlimaza commented 4 years ago

Here's the error message when trying to checkout - Screen Shot 2020-10-14 at 11 24 29

gausam commented 4 years ago

Thanks, Andrew 👍 I've added adjustments to handle the renewal scenario and I successfully tested with scenarios: