Automattic\WooCommerce\Blocks\Domain\Services

CheckoutLink::handle_checkout_link_endpointpublicWC 1.0

Handle the checkout link endpoint.

Method of the class: CheckoutLink{}

No Hooks.

Returns

null. Nothing (null).

Usage

$CheckoutLink = new CheckoutLink();
$CheckoutLink->handle_checkout_link_endpoint();

CheckoutLink::handle_checkout_link_endpoint() code WC 10.8.1

public function handle_checkout_link_endpoint() {
	if ( ! get_query_var( 'checkout-link' ) ) {
		return;
	}

	if ( ! $this->validate_checkout_link() ) {
		$redirect = add_query_arg( 'wc_error', rawurlencode( __( 'The provided checkout link was out of date or invalid. No products were added to the cart.', 'woocommerce' ) ), wc_get_cart_url() );
	} else {
		wc()->cart->empty_cart();
		$redirect = $this->get_checkout_link();
	}

	wp_safe_redirect( $redirect );
	exit;
}