HOME»Blog»WooCommerce»How To Get WooCommerce Page URLs in Themes/Plugins

How To Get WooCommerce Page URLs in Themes/Plugins

Advertise Here
Get WooCommerce Page URLs

WooCommerce uses various pages and endpoints to structure the frontend. Being a developer, I need to keep track of all those and here is what I use to get WooCommerce Page URLs in your custom themes or plugins when needed. The codes are updated as per WooCommerce version 4.6.1


WooCommerce uses 4 static pages to process the entire shopping process. Shop Page (It’s basically act as the archive for the product post type), My Account Page (This is where the user details like profile and orders are shown), Cart and Checkout Page. Let’s get the URLs for those pages.

Shop Page URL

There are mainly two ways to get the Shop page URL (Page set as Shop Page in WooCommerce settings).

wc_get_page_permalink( 'shop' );

//Alternative
get_permalink( wc_get_page_id( 'shop' ) );

My Account Page URL

wc_get_page_permalink( 'myaccount' );

//Alternative
get_permalink( wc_get_page_id( 'myaccount' ) );

Cart Page URL

There may be like 3~4 ways to get the URL, but WooCommerce provides a built-in function which retrieves the URL for you.

wc_get_cart_url();

//Alternatives
wc_get_page_permalink( 'cart' );
get_permalink( wc_get_page_id( 'cart' ) );

Checkout Page URL

Similar to Cart Page, there are a few ways to retrieve the checkout page url. Of course, the built-in WooCommerce function is recommended.

wc_get_checkout_url();

//Alternatives
wc_get_page_permalink( 'checkout' );
get_permalink( wc_get_page_id( 'checkout' ) );

My Account Endpoints

WooCommerce uses endpoints to group the different sections of the page. The endpoints are setup as the tabs found the My account page. The My account page has 9 endpoints and urls can be configured in WooCommerce settings.

wc_get_account_endpoint_url( 'endpointname' ); //Replace 'endpointname' with names below

Here is the list of the endpoints that can be called.

//Main Dashboard 
dashboard

//View all orders
orders
	
//View Order Details
view-order

//Available Downloads
downloads //For Downloadable products

//Customer Profile
edit-account

//View/Edit Addresses
edit-address

//Stored Payment Methods
payment-methods

//Retrieve Password
lost-password

//Logout
customer-logout

Checkout Endpoints

Similar to my account page, WooCommerce uses endpoints to further group the checkout experience. There are 5 endpoints in checkout page and can be configured from WooCommerce Settings.

wc_get_endpoint_url( 'endpointname', '', wc_get_checkout_url() );

The first parameter is the endpoint name you want to retrieve the URL, second parameter is value (which is used to append any value to the endpoint url, and usually stays empty) and the third parameter is the url where you want the endpoint to be added.

Here is the list of all the default endpoint names for Checkout page.

//Pay for an Order
order-pay

//Order Received (The Thankyou Page)
order-received

//Add Payment Method
add-payment-method

//Delete Payment Method
delete-payment-method

//Set Default Payment Method
set-default-payment-method

That’s it. That’s how you get WooCommerce Page URLs in your code. Do let me know your thoughts in comments.

Leave a comment

Your email address will not be published. Required fields are marked *

Join PixelNet Community

+ + + + = 545

Join our mailing list and get exiting WordPress resources and offers directly in your Inbox.No SPAM Promise

Advertise Here