Tribe__Tickets_Plus__Commerce__WooCommerce__Cart::get_tickets_in_cart( array $tickets = array(), string $provider = null )
Filter the tickets in the Cart to have the WooCommerce class as a provider so Attendee Registration works.
Contents
Parameters
- $tickets
-
(array) (Optional) List of tickets.
Default value: array()
- $provider
-
(string) (Optional) Provider of tickets to get (if set).
Default value: null
Return
(array) List of tickets.
Source
File: src/Tribe/Commerce/WooCommerce/Cart.php
public function get_tickets_in_cart( $tickets = [] ) {
// If the cart is null, we need to bail to prevent any "Call to a member function on null" errors
if ( is_null( WC()->cart ) ) {
return [];
}
$contents = WC()->cart->get_cart_contents();
if ( empty( $contents ) ) {
return $tickets;
}
$event_key = tribe( 'tickets-plus.commerce.woo' )->event_key;
foreach ( $contents as $item ) {
$woo_check = get_post_meta( $item['product_id'], $event_key, true );
if ( empty( $woo_check ) ) {
continue;
}
$tickets[ $item['product_id'] ] = $item['quantity'];
}
return $tickets;
}
Changelog
| Version | Description |
|---|---|
| 4.9 | Introduced. |