How to Get Default Page URLs
If you go to Pages > All Pages after WooCommerce installation, you will notice that a couple more pages appeared there. These are kind of system pages in WooCommerce and required to provide your shop visitors proper eCommerce user experience.

Sometimes, and I might say – very often, when coding something for WooCommerce we need to get these pages URLs programmatically. We can’t use something like site_url( 'cart' )
, because website administrators allowed to change the system pages URLs, for example to use example.com/basket
instead of example.com/cart
and so on.
Luckily there are a couple functions in WooCommerce that allow to get these page URLs dynamically.
Get Cart URL
You can easily get the URL of your store cart page dynamically with wc_get_cart_url()
function.
<a href="<?php echo wc_get_cart_url() ?>">Cart</a>
This function doesn’t have any parameters and works on the base of wc_get_page_permalink( 'cart' )
, which also works on the base of wc_get_page_id( 'cart' )
which retrieves the cart page ID from the options with the key woocommerce_cart_page_id
.
There is also a filter hook woocommerce_get_cart_url
with the only parameter – the cart URL the function returns.
Get Checkout Page URL
There is a similar situation with the checkout page. You can use wc_get_checkout_url()
function for that, which doesn’t accept any parameters and works on the base of wc_get_page_permalink( 'checkout' )
, which also works on the base of wc_get_page_id( 'checkout' )
which retrieves the checkout page ID from the options with the key woocommerce_checkout_page_id
.
<a href="<?php echo wc_get_checkout_url() ?>">Checkout</a>
The function also has a hook inside it woocommerce_get_checkout_url
, so you can filter the result URL everywhere on the store.
There is also an SSL check inside it. If the option Force SSL is enabled, it adds https to the url.
Checkout Endpoints
If you go to WooCommerce > Settings > Advanced, you will find out the Checkout endpoints. Not sure how to explain it the best – it means, that there are some virtual pages that work on base of the checkout page code. These pages have the same URL as the checkout page but an additional endpoint is added to the end of the checkout page URL.

And you do not have to do it manually like wc_get_checkout_url() . 'add-payment-method'
because you will get 404 error if the above settings will be changed.
There is a special function for this purpose wc_get_endpoint_url()
. The correct usage for the Add payment method page is:
<?php
$url = wc_get_endpoint_url( 'add-payment-method', '', wc_get_checkout_url() );
?>
<a href="<?php echo $url ?>">Add Payment Method</a>
So the first parameter is the default endpoint name, you can find it on the screenshot by the way, the second parameter is usually empty and the third parameter is the URL we are going to add endpoint to.
Get Account Page URL
My account page doesn’t have a specific function, so you can only use wc_get_page_permalink()
.
<a href="<?php echo wc_get_page_permalink( 'myaccount' ) ?>">My account</a>
You’ve been looking for a filter for this page, don’t be sad, because you still can use a filter which is a part of wc_get_page_permalink()
function.
Filter name is woocommerce_get_' . $page . '_page_permalink
, so it can be used for the cart and checkout pages as well.
- Cart
woocommerce_get_cart_page_permalink
- Checkout
woocommerce_get_checkout_page_permalink
- My account
woocommerce_get_myaccount_page_permalink
My account page ID is stored in wp_options under the key woocommerce_myaccount_page_id
.
My Account Endpoints
Just under the Checkout endpoints you will find Account endpoints.

Most of them you will find in My Account menu as subpages.

The thing is that we have a specific function which allows us to get those pages dynamically – wc_get_account_endpoint_url()
.
You may think – ok, what is the problem, I can add it manually to the URL like this: wc_get_page_permalink( 'myaccount' ) . 'orders'
. Please do not! Because in that case if the endpoint name will be changed in settings, you will get 404! So the correct way:
$orders_url = wc_get_account_endpoint_url( 'orders' );
So the function accepts the default endpoint names:
dashboard
– Dashboard, if you pass it, the function just returnswc_get_page_permalink( 'myaccount' )
,orders
– Orders,view-order
– View order,downloads
– Downloads,edit-account
– Edit account, by the way you can also usewc_customer_edit_account_url()
function here,edit-address
– Addresses,payment-methods
– Payment methods,lost-password
– Lost password,customer-logout
– Logout, when passed, the function just returns the result ofwc_logout_url()
function.
There is also wc_lostpassword_url()
function by the way.
Get Shop Page URL
The last but not least, the shop page.
<a href="<?php echo wc_get_page_permalink( 'shop' ) ?>">Continue shopping</a>
Its ID in wp_options
under the key woocommerce_shop_page_id
.

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
Hi,
This is the best and most comprehensive article in this topic.
Good work!