
Shop URL
Get the WooCommerce Shop URL (this is the root category page) with the following:
$shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
My Account URL
You can get the WooCommerce My Account URL by using the woocommerce_myaccount_page_id
option:
$myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' ); if ( $myaccount_page_id ) { $myaccount_page_url = get_permalink( $myaccount_page_id ); }
Cart URL
The WooCommerce Cart URL can be retrieved with a call to the cart object’s get_cart_url()
method:
global $woocommerce; $cart_url = $woocommerce->cart->get_cart_url();
Checkout URL
Similar to getting the cart URL, the WooCommerce Checkout URL can be retrieved with a call to the cart object’s get_checkout_url()
method:
global $woocommerce; $checkout_url = $woocommerce->cart->get_checkout_url();
Payment Page URL
This is the payment page URL used to collect payment information after the checkout page by redirect/hosted payment gateways. The path typically looks like /checkout/pay/
. Get this URL with the following:
$payment_page = get_permalink( woocommerce_get_page_id( 'pay' ) ); // make ssl if needed if ( get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) $payment_page = str_replace( 'http:', 'https:', $payment_page );
Logout URL
This example will generate a WordPress logout URL that brings the user back to the Account area of the site:
$myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' ); if ( $myaccount_page_id ) { $logout_url = wp_logout_url( get_permalink( $myaccount_page_id ) ); if ( get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) $logout_url = str_replace( 'http:', 'https:', $logout_url ); }
how to find track my order page url??
Hey rashed, good question. Actually I don’t think there’s a programmatic way of retrieving the url for the “track my order” page, just because it’s not one of the special WooCommerce pages, it’s handled by the shortcode
[woocommerce_order_tracking]
so you can just go to your WordPress admin Pages area and find/create the page. Hope this helpsGood stuff!
Nice, Very useful. Thanks
Hi Justin,
Good day!
What page of woocommerce can I see this code? Since I’ll be changing the URL for the Logout to Shopping page. Thanks for the tutorial. I am hoping for your kind response soon.
Thanks and have a great day ahead.
Best regards,
Mariz
Try the WooCommerce > Settings > Pages page 🙂
Hi, great post !! I would like to know how to get the url for page “My Orders”, I’m not sure if there is a specific page for the customers which shows their orders.
Thanks!
The “My Recent Orders” section is on the “My Account” page, so you can use the my account code above to get the URL 🙂
Hello can i change WooCommerce url like this ?
Is this recommended if yes how i can do this?
Cateogry:
product-category/ to say: /category/
Shop by category:
shop-by-category/ to /shop/
Yep, on the Settings > Permalink menu 🙂
Very useful. Is there a way to fix the permalinks if they’re incorrect? I migrated a copy of a client’s site to my local machine, but the links for My Account and Checkout are incorrect, yet all the places where you can set the site’s address are correct.
Hello.
How can I change default shop url from http://www.mydomain.com/shop to http://www.mydomain.com/
Thanx
Try to change Settings > Reading > Front Page to “Shop” 🙂
Thanks, you can also use the following:
woocommerce_get_page_id( ‘cart’ );
woocommerce_get_page_id( ‘change_password’ );
woocommerce_get_page_id( ‘checkout’ );
woocommerce_get_page_id( ‘edit_address’ );
woocommerce_get_page_id( ‘logout’ );
woocommerce_get_page_id( ‘lost_password’ );
woocommerce_get_page_id( ‘myaccount’ );
woocommerce_get_page_id( ‘pay’ );
woocommerce_get_page_id( ‘view_order’ );
woocommerce_get_page_id( ‘shop’ );
woocommerce_get_page_id( ‘terms’ );
woocommerce_get_page_id( ‘thanks’ );
Thanks, it’s very useful for me 🙂
Thanks for sharing it, that first link to the shop was exactly what I needed.
Cheers.
Thank you for all the great info Justin!
Is there an easy way to redirect to a web address after checkout?
Do you mean an external page, or just another page on your site? I’d recommend using the ‘Thank you’ page right after checkout, as a lot of plugins use this page for tracking and to fire various other scripts.
How do I insert another URL?
woocommerce_get_page_id( ‘URL’ );
Great info, thank you.
How would I get to the Woocommerce URL for http://yoursite.com/checkout/shipping-addresses/ found in the Woocommerce Multiple Shipping Address add-on?
Thank you!
Hi, is there an url where I can automatically download new orders on my pc?
Hey there, to get orders out of WooCommerce you’d have to use an exporter, such as the CSV Order export (gives you an Excel file).
How to get the single product page url in Woocommerce?.
Since you’ll be getting a URL for a particular product, you can get the permalink based on the page/post id using get_permalink.
Saves my day, thanks 🙂
I want user to redirected to checkout page if cart contains a certain category of product , can you lease help me ?
There’s a plugin to create thank you page redirects that has category support coming soon, would recommend giving that a go.