Notice: WP_Scripts::localize was called incorrectly. The $l10n parameter must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script() function instead. Please see Debugging in WordPress for more information. (This message was added in version 5.7.0.) in /home/customer/www/ on line 5313
How To Get WooCommerce Page URLs in Themes/Plugins | PixelNet
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' );

get_permalink( wc_get_page_id( 'shop' ) );

My Account Page URL

wc_get_page_permalink( 'myaccount' );

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_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_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 

//View all orders
//View Order Details

//Available Downloads
downloads //For Downloadable products

//Customer Profile

//View/Edit Addresses

//Stored Payment Methods

//Retrieve Password


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 Received (The Thankyou Page)

//Add Payment Method

//Delete 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

+ + + + = 1,230

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

Advertise Here