WC_Shortcode_Checkout::checkout()private staticWC 1.0

Show the checkout.

Method of the class: WC_Shortcode_Checkout{}

Return

null. Nothing (null).

Usage

$result = WC_Shortcode_Checkout::checkout();

WC_Shortcode_Checkout::checkout() code WC 9.4.2

private static function checkout() {
	// Show non-cart errors.
	do_action( 'woocommerce_before_checkout_form_cart_notices' );

	// Check cart has contents.
	if ( WC()->cart->is_empty() && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_redirect_empty_cart', true ) ) {
		return;
	}

	// Check cart contents for errors.
	do_action( 'woocommerce_check_cart_items' );

	// Calc totals.
	WC()->cart->calculate_totals();

	// Get checkout object.
	$checkout = WC()->checkout();

	if ( empty( $_POST ) && wc_notice_count( 'error' ) > 0 ) { // WPCS: input var ok, CSRF ok.

		wc_get_template( 'checkout/cart-errors.php', array( 'checkout' => $checkout ) );
		wc_clear_notices();

	} else {

		$non_js_checkout = ! empty( $_POST['woocommerce_checkout_update_totals'] ); // WPCS: input var ok, CSRF ok.

		if ( wc_notice_count( 'error' ) === 0 && $non_js_checkout ) {
			wc_add_notice( __( 'The order totals have been updated. Please confirm your order by pressing the "Place order" button at the bottom of the page.', 'woocommerce' ) );
		}

		wc_get_template( 'checkout/form-checkout.php', array( 'checkout' => $checkout ) );

	}
}