Tribe__Tickets_Plus__Commerce__WooCommerce__Main::process_front_end_tickets_form()
Grabs the submitted front end tickets form and adds the products to the cart
Source
File: src/Tribe/Commerce/WooCommerce/Main.php
public function process_front_end_tickets_form() {
parent::process_front_end_tickets_form();
global $woocommerce;
// We just want to process wootickets submissions here.
if (
empty( $_REQUEST['wootickets_process'] )
|| intval( $_REQUEST['wootickets_process'] ) !== 1
|| empty( $_POST['product_id'] )
) {
return;
}
foreach ( (array) $_POST['product_id'] as $product_id ) {
$quantity = isset( $_POST[ 'quantity_' . $product_id ] ) ? (int) $_POST[ 'quantity_' . $product_id ] : 0;
$optout = isset( $_POST[ 'optout_' . $product_id ] ) ? (bool) $_POST[ 'optout_' . $product_id ] : false;
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity );
$cart_data = array(
'attendee_optout' => $optout,
);
if ( $passed_validation && $quantity > 0 ) {
$woocommerce->cart->add_to_cart( $product_id, $quantity, 0, array(), $cart_data );
}
}
if ( empty( $_POST[ Tribe__Tickets_Plus__Meta__Storage::META_DATA_KEY ] ) ) {
return;
}
$cart_url = $this->get_cart_url();
set_transient( $this->get_cart_transient_key(), $cart_url );
wp_safe_redirect( $cart_url );
tribe_exit();
}