Skip to content

Commit

Permalink
Virtual inventory needs to return total quantity when $type not passed
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Jan 24, 2024
1 parent ffe0482 commit efbd0d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/mt-add-to-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function mt_add_to_cart_form( $content, $event = false, $view = 'calendar', $tim
$default_available = apply_filters( 'mt_default_available', 100, $registration );
$available = ( 'general' === $registration['counting_method'] ) ? $default_available : $registration['total'];
$tickets_data = mt_check_inventory( $event_id );
$tickets_remaining = ( 'general' === $registration['counting_method'] ) ? $default_available : $tickets_data['available'];
$tickets_remaining = ( 'general' === $registration['counting_method'] ) ? $default_available : mt_check_inventory( $event_id )['available'];
$tickets_sold = $tickets_data['sold'];
/**
* Filter when online ticket sales should close based on availability. Default 0; sales close when sold out.
Expand Down
9 changes: 8 additions & 1 deletion src/mt-cart-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,14 @@ function mt_check_inventory( $event_id, $type = '' ) {
}
// Virtual inventory holds tickets in carts but not yet sold.
$virtual_inventory = get_post_meta( $event_id, '_mt_virtual_inventory', true );
$current_virtual = isset( $virtual_inventory[ $type ] ) ? $virtual_inventory[ $type ] : 0;
if ( '' !== $type ) {
$current_virtual = isset( $virtual_inventory[ $type ] ) ? $virtual_inventory[ $type ] : 0;
} else {
$current_virtual = 0;
foreach ( $virtual_inventory as $type => $quantity ) {
$current_virtual += (int) $quantity;
}
}
/**
* Filter whether a particular event uses virtual inventory. Return 'virtual' to use the virtual inventory, 'actual' to use completed purchases only.
*
Expand Down

0 comments on commit efbd0d2

Please sign in to comment.