Reserve Your Free Seat for Our Next WooCommerce Class! Search
Business Bloomer
  • Business Bloomer Club
  • WooCommerce Plugins
  • WooCommerce Tips
  • Log In
  • 0
  • Business Bloomer Club
  • WooCommerce Plugins
  • WooCommerce Tips
  • Log In
  • Search
  • Contact
  • Cart
WooCommerce Code Snippets Cart Page Checkout Page My Account Permalink Single Product Page Thank You Page

WooCommerce: Easily Get Cart, Checkout, Account, Product URLs

Last Revised: May 2023

STAY UPDATED

Just so you know, there is no need to hardcode WooCommerce URLs in your custom code! In fact, WooCommerce gives us helpful shortcut functions that we can reuse in our code to get cart, checkout, account and product URLs without wondering if they have been modified by the website owner e.g. example.com/cart to example.com/basket.

In this way, you can always make sure you’re getting the correct URLs without wasting time looking for page/product slugs. Enjoy!

No need to hardcode “https://——-.h4.conves.io/cart/” in my custom WooCommerce code… I can just use wc_get_cart_url()! Find more shortcuts below.
Table Of Contents
  1. WooCommerce Product URL
  2. WooCommerce Cart URL
  3. WooCommerce Checkout URL
  4. WooCommerce Shop URL
  5. WooCommerce My Account URLs
  6. WooCommerce Product Category / Product Tag URL
  7. WooCommerce Thank You Page URL

WooCommerce Product URL

/* On a single product page */
get_the_permalink()

/* If you have the product ID */
get_permalink( $product_id )

/* If you have the $product object */
$product->get_permalink()

WooCommerce Cart URL

wc_get_cart_url()

WooCommerce Checkout URL

wc_get_checkout_url()

WooCommerce Shop URL

wc_get_page_permalink( 'shop' )

WooCommerce My Account URLs

/* My Account Page */
wc_get_page_permalink( 'myaccount' );

/* My Account Endpoints */
wc_get_account_endpoint_url( 'edit-address' );
wc_get_account_endpoint_url( 'edit-account' );
wc_get_account_endpoint_url( 'payment-methods' );
wc_get_account_endpoint_url( 'lost-password' );
wc_get_account_endpoint_url( 'customer-logout' );
wc_get_account_endpoint_url( 'dashboard' );
// ETC.

WooCommerce Product Category / Product Tag URL

get_term_link( 'tables', 'product_cat' )
get_term_link( 'mixed', 'product_tag' )

WooCommerce Thank You Page URL

wc_get_endpoint_url( 'order-received', $order_id, wc_get_checkout_url() )

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce Visual Hook Guide: Single Product Page
    Here’s a visual hook guide for the WooCommerce Single Product Page. This is part of my “Visual Hook Guide Series“, through which you can find…
  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max…
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to…
  • WooCommerce: How to Fix the “Cart is Empty” Issue
    For some reason, sometimes you add products to cart but the cart page stays empty (even if you can clearly see the cart widget has…
  • WooCommerce: Separate Login, Registration, My Account Pages
    There are times when you need to send logged out customers to a Login page and unregistered customers to a standalone Register page. As you…

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Cancel reply

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


Search WooCommerce Tips

Popular Searches: Visual Hook Guides - Checkout Page - Cart Page - Single Product Page - Add to Cart - Emails - Shipping - Prices - Hosting

Recent Articles

  • WooCommerce: How to Configure Product and Order Sync
  • WooCommerce: “Beautify” Item Meta in Order Emails
  • WooCommerce: Per-Product Checkout Fees / Tariffs
  • WooCommerce: Auto-Cancel Orders After 3 Failed Payments
  • WooCommerce: Bulk Delete Pending / Failed Scheduled Actions

Latest Comments

  1. Tiago Sartor on WooCommerce: Access Thank You Page from Order Admin
  2. Piotr on WooCommerce: Replace Variable Price With Active Variation Price
  3. Rodolfo Melogli on WooCommerce: Redirect Empty Paginated Category Pages (404)

Find Out More

  • Become a WooCommerce Expert
  • Business Bloomer Club
  • WooCommerce Blog
  • WooCommerce Weekly
  • Contact

Contact Info

Ciao! I'm Rodolfo Melogli, an Italian Civil Engineer who has turned into an international WooCommerce expert. You can contact me here:

Twitter: @rmelogli

Get in touch: Contact Page

Business Bloomer © 2011-2025 - VAT IT02722220817 - Terms of Use - Privacy Policy

Cart reminder?

x