Ticket::decrease_ticket_stock_by( int $ticket_id, int $quantity = 1 )
Decrease the ticket stock.
Contents
Parameters
- $ticket_id
-
(int) (Required) int The ticket post ID.
- $quantity
-
(int) (Optional) int The quantity to decrease the ticket stock by.
Default value: 1
Return
(bool|int)
Source
File: src/Tickets/Commerce/Ticket.php
public function decrease_ticket_stock_by( int $ticket_id, int $quantity = 1 ) {
$stock = (int) get_post_meta( $ticket_id, static::$stock_meta_key, true ) - $quantity;
$stock = max( 0, $stock );
return update_post_meta( $ticket_id, static::$stock_meta_key, $stock );
}
Changelog
| Version | Description |
|---|---|
| 5.8.3 | Introduced. |