Tribe__Tickets__RSVP::increase_ticket_sales_by( int $ticket_id, int $quantity = 1 )
Increase the sales for a ticket by a specific quantity.
Contents
Parameters
- $ticket_id
-
(int) (Required) The ticket post ID.
- $quantity
-
(int) (Optional) The quanitity to increase the ticket sales by.
Default value: 1
Return
(int) The new sales amount.
Source
File: src/Tribe/RSVP.php
public function increase_ticket_sales_by( $ticket_id, $quantity = 1 ) {
// Adjust sales.
$sales = (int) get_post_meta( $ticket_id, 'total_sales', true ) + $quantity;
update_post_meta( $ticket_id, 'total_sales', $sales );
// Adjust stock.
$stock = (int) get_post_meta( $ticket_id, '_stock', true ) - $quantity;
// Prevent negatives.
$stock = max( $stock, 0 );
update_post_meta( $ticket_id, '_stock', $stock );
return $sales;
}
Changelog
| Version | Description |
|---|---|
| 5.1.0 | Introduced. |