Cart::parse_request()
Prepares the data from the Tickets form.
Return
(bool)
Source
File: src/Tickets/Commerce/Cart.php
public function parse_request() {
// When it's not the current page we just bail.
if ( ! $this->is_current_page() ) {
return false;
}
$data = $this->prepare_data( $_POST );
/**
* Hook to inject behavior before cart is processed, if you need to change the data that will be used, you
* should look into `tec_tickets_commerce_cart_prepare_data`.
*
* @since 5.1.9
*
* @param array $data Data used to process the cart.
*/
do_action( 'tec_tickets_commerce_cart_before_process', $data );
$processed = $this->process( $data );
/**
* Hook to inject behavior after cart is processed.
*
* @since 5.1.9
*
* @param array $data Data used to process the cart.
* @param bool $processed Whether or not we processed the data.
*/
do_action( 'tec_tickets_commerce_cart_after_process', $data, $processed );
if ( static::REDIRECT_MODE === $this->get_mode() ) {
$redirect_url = tribe( Checkout::class )->get_url();
/**
* Filter the base redirect URL for cart to checkout.
*
* @since 5.2.0
*
* @param string $redirect_url Redirect URL.
* @param array $data Data that we just processed on the cart.
*/
$redirect_url = apply_filters( 'tec_tickets_commerce_cart_to_checkout_redirect_url_base', $redirect_url, $data );
if (
! isset( $_COOKIE[ $this->get_cart_hash() ] )
|| ! $_COOKIE[ $this->get_cart_hash() ]
) {
$redirect_url = add_query_arg( [ static::$cookie_query_arg => $this->get_cart_hash() ], $redirect_url );
}
/**
* Which url it redirects after the processing of the cart.
*
* @since 5.1.9
*
* @param string $redirect_url Which url we will direct after processing the cart. Defaults to Checkout page.
* @param array $data Data that we just processed on the cart.
*/
$redirect_url = apply_filters( 'tec_tickets_commerce_cart_to_checkout_redirect_url', $redirect_url, $data );
if ( null !== $redirect_url ) {
wp_safe_redirect( $redirect_url );
tribe_exit();
}
}
return true;
}
Changelog
| Version | Description |
|---|---|
| 5.1.9 | Introduced. |