WordPress at Your Fingertips

wc_get_checkout_url()WC 2.5.0

Gets the url to the checkout page.

Hooks from the function

Return

String. Url to checkout page

Usage

wc_get_checkout_url();

Examples

0

#1 Display a link to the checkout page

<a class="checkout-link" href="<?php echo esc_url( wc_get_checkout_url() ); ?>">
	Ordering
</a>

Changelog

Since 2.5.0 Introduced.

wc_get_checkout_url() code WC 8.7.0

function wc_get_checkout_url() {
	$checkout_url = wc_get_page_permalink( 'checkout' );
	if ( $checkout_url ) {
		// Force SSL if needed.
		if ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) {
			$checkout_url = str_replace( 'http:', 'https:', $checkout_url );
		}
	}

	return apply_filters( 'woocommerce_get_checkout_url', $checkout_url );
}
1 comment
    Log In