wc_get_checkout_url()
Returns a link to the checkout page.
If the checkout page does not exist, the function get_home_url() will be executed and the URL of the site's home page will be returned.
Hooks from the function
Returns
String. A link to the checkout page or the site's home page if the page does not exist.
Usage
wc_get_checkout_url();
Examples
#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() wc get checkout url code WC 10.3.5
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 );
}