Cart::add_ticket( int $ticket_id, int $quantity = 1, array $extra_data = array() )

Handles the process of adding a ticket product to the cart.

If the cart contains a line item for the product, this will replace the previous quantity. If the quantity is zero and the cart contains a line item for the product, this will remove it.


Parameters

$ticket_id

(int) (Required) Ticket ID.

$quantity

(int) (Optional) Ticket quantity to add.

Default value: 1

$extra_data

(array) (Optional) Extra data to send to the cart item.

Default value: array()


Top ↑

Source

File: src/Tickets/Commerce/Cart.php

	public function add_ticket( $ticket_id, $quantity = 1, array $extra_data = [] ) {
		$cart = $this->get_repository();

		// Enforces that the min to add is 1.
		$quantity = max( 1, (int) $quantity );

		// Add to / update quantity in cart.
		$cart->add_item( $ticket_id, $quantity, $extra_data );
	}

Top ↑

Changelog

Changelog
Version Description
5.1.9 Introduced.