add fulcrm_shoppingcart_eventslot_has_capacity
This commit is contained in:
parent
abaca6c0a4
commit
f58c48dc23
@ -499,6 +499,35 @@ function fulcrm_shoppingcart_event_has_capacity( $event_id ) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fulcrm_shoppingcart_eventslot_has_capacity( $eventslot_id ) {
|
||||||
|
$capacity = null;
|
||||||
|
$count = null;
|
||||||
|
$api_data = fulcrm_apiv2_GET( 'eventslot/' . $event_id . '/',
|
||||||
|
$query = array( 'expand' => 'eventpart,eventpart.event' ) );
|
||||||
|
if ( $api_data[ 'success' ] ) {
|
||||||
|
$capacities = array( $api_data[ 'data' ][ 'eventpart' ][ 'event' ][ 'capacity' ],
|
||||||
|
$api_data[ 'data' ][ 'eventpart' ][ 'capacity' ],
|
||||||
|
$api_data[ 'data' ][ 'capacity' ] );
|
||||||
|
foreach ( $capacities as $cap ) {
|
||||||
|
if ( !is_null( $cap ) )
|
||||||
|
$capacity = $cap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$api_data = fulcrm_apiv2_GET( 'eventslotbooking/', $query = array( 'eventslot' => $eventslot_id,
|
||||||
|
'eventbooking__confirmed__isnull' => 'False',
|
||||||
|
'eventbooking__cancelled__isnull' => 'True',
|
||||||
|
) );
|
||||||
|
if ( $api_data[ 'success' ] )
|
||||||
|
$count = $api_data[ 'data' ][ 'count' ];
|
||||||
|
|
||||||
|
if ( !is_null( $capacity ) && !is_null( $count ) ) {
|
||||||
|
if ( $count >= $capacity )
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $person, $eventbookingtype, $product ) {
|
function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $person, $eventbookingtype, $product ) {
|
||||||
$form = array();
|
$form = array();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user