Skip to content

Commit

Permalink
Pass correct ticket remaining count & simplify logic
Browse files Browse the repository at this point in the history
Fixes #72
  • Loading branch information
joedolson committed Oct 6, 2024
1 parent ed4711d commit 421f099
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/mt-add-to-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ function mt_ticket_row( $event_id, $registration, $ticket_type, $type, $availabl
$available
);

$hide_remaining = mt_hide_remaining( $tickets_remaining );
$hide_remaining = mt_hide_remaining( $remaining );
$remaining_text = $ticket_price_label . sprintf(
apply_filters(
'mt_tickets_remaining_discrete_text',
Expand Down Expand Up @@ -780,12 +780,11 @@ function mt_event_status( $event_id = false ) {
function mt_hide_remaining( $tickets_remaining ) {
$options = mt_get_settings();
// If hide remaining is enabled, set as hidden.
$hide_remaining = ( isset( $options['mt_hide_remaining'] ) && 'true' === $options['mt_hide_remaining'] ) ? ' hiding' : '';
$remaining_limit = isset( $options['mt_hide_remaining_limit'] ) ? absint( $options['mt_hide_remaining_limit'] ) : 0;
// Hide tickets if there are more than x tickets available if limit is set.
$hide_limiting = ( isset( $options['mt_hide_remaining_limit'] ) && 0 !== $remaining_limit && ( $tickets_remaining > $remaining_limit ) ) ? ' hiding' : '';
$hide_remaining = ( isset( $options['mt_hide_remaining'] ) && 'true' === $options['mt_hide_remaining'] ) ? true : false;
$hidden_class = ( ( $hide_remaining && ! $remaining_limit ) || ( $hide_remaining && $tickets_remaining > $remaining_limit ) ) ? ' hiding' : '';

return ( isset( $options['mt_hide_remaining_limit'] ) ) ? $hide_limiting : $hide_remaining;
return $hidden_class;
}
/**
* Test whether the current ticket type is admin-only
Expand Down

0 comments on commit 421f099

Please sign in to comment.