Ticket::decrease_ticket_stock_by( int $ticket_id, int $quantity = 1 )

Decrease the ticket stock.


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


Top ↑

Return

(bool|int)


Top ↑

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 );
	}

Top ↑

Changelog

Changelog
Version Description
5.8.3 Introduced.