tribe_tickets_delete_capacity( int|WP_Post $object )
Removes all meta for a given object capacity. Object can be a ticket, or an event/post with tickets.
Contents
Note, you can pass an event/post to this function and it will merrily change the meta values for the event – not for the tickets!
Parameters
- $object
-
(int|WP_Post) (Required) WP_Post (or ID of post) We are trying to delete capacity from.
Return
(int|false)
Source
File: src/template-tags/tickets.php
function tribe_tickets_delete_capacity( $object ) {
if ( ! $object instanceof WP_Post ) {
$object = get_post( $object );
}
if ( ! $object instanceof WP_Post ) {
return false;
}
$deleted = delete_post_meta( $object->ID, tribe( 'tickets.handler' )->key_capacity );
if ( ! $deleted ) {
return $deleted;
}
// We only apply these when we are talking about event-like posts
if ( tribe_tickets_post_type_enabled( $object->post_type ) ) {
$shared_cap_object = new Tribe__Tickets__Global_Stock( $object->ID );
$shared_cap_object->disable();
// This is mostly to make sure
delete_post_meta( $object->ID, Tribe__Tickets__Global_Stock::GLOBAL_STOCK_LEVEL );
delete_post_meta( $object->ID, Tribe__Tickets__Global_Stock::TICKET_STOCK_MODE );
delete_post_meta( $object->ID, Tribe__Tickets__Global_Stock::TICKET_STOCK_CAP );
}
return $deleted;
}
Changelog
| Version | Description |
|---|---|
| 4.6.2 | Introduced. |