Skip to content

Commit

Permalink
Merge pull request #12 from kimcoleman/max-min-rules
Browse files Browse the repository at this point in the history
Min and max seats logic
  • Loading branch information
dparker1005 authored Dec 5, 2023
2 parents 127aa50 + 1139331 commit 0012c15
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions includes/edit-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function pmprogroupacct_pmpro_membership_level_before_content_settings( $level )
<label for="pmprogroupacct_total_seats"><?php esc_html_e( 'Total Seats', 'pmpro-group-accounts' ); ?></label>
</th>
<td>
<input id="pmprogroupacct_total_seats" name="pmprogroupacct_total_seats" type="number" min="0" value="<?php echo esc_attr( $settings['min_seats'] ); ?>" />
<input id="pmprogroupacct_total_seats" name="pmprogroupacct_total_seats" type="number" min="0" max="4294967295" value="<?php echo esc_attr( $settings['min_seats'] ); ?>" />
<p class="description"><?php esc_html_e( 'The total number of seats that are included in this group. Note: the group account owner does not count toward this total.', 'pmpro-group-accounts' ); ?></p>
</td>
</tr>
Expand All @@ -82,7 +82,7 @@ function pmprogroupacct_pmpro_membership_level_before_content_settings( $level )
<label for="pmprogroupacct_min_seats"><?php esc_html_e( 'Minimum Seats', 'pmpro-group-accounts' ); ?></label>
</th>
<td>
<input id="pmprogroupacct_min_seats" name="pmprogroupacct_min_seats" type="number" min="0" value="<?php echo esc_attr( $settings['min_seats'] ); ?>" />
<input id="pmprogroupacct_min_seats" name="pmprogroupacct_min_seats" type="number" min="0" max="4294967295" value="<?php echo esc_attr( $settings['min_seats'] ); ?>" />
<p class="description"><?php esc_html_e( 'The minimum number of seats that can be added at checkout.', 'pmpro-group-accounts' ); ?></p>
</td>
</tr>
Expand All @@ -91,7 +91,7 @@ function pmprogroupacct_pmpro_membership_level_before_content_settings( $level )
<label for="pmprogroupacct_max_seats"><?php esc_html_e( 'Maximum Seats', 'pmpro-group-accounts' ); ?></label>
</th>
<td>
<input id="pmprogroupacct_max_seats" name="pmprogroupacct_max_seats" type="number" min="0" value="<?php echo esc_attr( $settings['max_seats'] ); ?>" />
<input id="pmprogroupacct_max_seats" name="pmprogroupacct_max_seats" type="number" min="0" max="4294967295" value="<?php echo esc_attr( $settings['max_seats'] ); ?>" />
<p class="description"><?php esc_html_e( 'The maximum number of seats that can be added at checkout. Note: the group account owner does not count toward this limit.', 'pmpro-group-accounts' ); ?></p>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion includes/manage-group-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ function pmprogroupacct_shortcode_manage_group() {
<div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>">
<div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-text' ); ?>">
<label for="pmprogroupacct_group_total_seats"><?php esc_html_e( 'Total Seats', 'pmpro-group-accounts' ); ?></label>
<input type="number" name="pmprogroupacct_group_total_seats" id="pmprogroupacct_group_total_seats" class="<?php echo pmpro_get_element_class( 'input' ); ?>" value="<?php echo esc_attr( $group->group_total_seats ); ?>">
<input type="number" max="4294967295" name="pmprogroupacct_group_total_seats" id="pmprogroupacct_group_total_seats" class="<?php echo pmpro_get_element_class( 'input' ); ?>" value="<?php echo esc_attr( $group->group_total_seats ); ?>">
</div> <!-- end .pmpro_checkout-field -->
</div> <!-- end .pmpro_checkout-fields -->
<div class="<?php echo pmpro_get_element_class( 'pmpro_submit' ); ?>">
Expand Down
10 changes: 10 additions & 0 deletions js/pmprogroupacct-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ jQuery( document ).ready( function( $ ) {
pmprogroupacct_update_edit_level_pricing_model_field_visibility();
} );

// Function to update the min value of max seats based on min seats.
function pmprogroupacct_update_max_seats() {
var minSeats = $( '#pmprogroupacct_min_seats' ).val();
$( '#pmprogroupacct_max_seats' ).attr( 'min', minSeats );
}
pmprogroupacct_update_max_seats();
$('#pmprogroupacct_min_seats').change(function() {
pmprogroupacct_update_max_seats();
});

// Function to toggle the warning based on the recurring checkbox
function pmprogroupacct_toggle_recurring_warning() {
var priceApplication = $('#pmprogroupacct_price_application').val();
Expand Down

0 comments on commit 0012c15

Please sign in to comment.