Search

WooCommerce Endpoints (2.1+)

WooCommerce 2.1 makes use of endpoints to show certain content to users on the frontend. This document explains what endpoints are, how we make use of them, how developers can use them, and what they replace when upgrading from WC 2.0.

What are endpoints? ↑ Back to Top

Endpoints are essentially an extra part in the website URL that we detect and show different content when present.

For example, you may have a ‘my account’ page shown on the URL yoursite.com/my-account. When the endpoint ‘edit-account’ is appended to this URL, making it ‘yoursite.com/my-account/edit-account‘ we show the Edit account page instead of the My account page.

This allows us to show different content without the need for multiple pages and shortcodes, thus reducing the amount of content we need to install.

What endpoints replace from WC 2.0 ↑ Back to Top

In previous versions of WooCommerce, pages and shortcodes were used instead for endpoint content. Examples of endpoints in WooCommerce include:

  • Edit account page (previously a page with the [woocommerce_edit_account] shortcode).
  • Edit address page (previously a page with the [woocommerce_edit_address] shortcode).
  • Change password page (previously a page with the [woocommerce_change_password] shortcode).
  • Lost password page (previously a page with the [woocommerce_lost_password] shortcode).
  • View order pages  (previously a page with the [woocommerce_view_order] shortcode).
  • Customer logout  (previously a page with the [woocommerce_logout] shortcode).
  • Checkout pay page  (previously a page with the [woocommerce_pay] shortcode).
  • Checkout thanks page  (previously a page with the [woocommerce_thankyou] shortcode).

If you are upgrading WooCommerce and wondering why these shortcodes no longer function, it’s because they no longer exist. Although WooCommerce attempts to remove these pages during upgrade, they may remain if they have been customized.

It is safe to remove these pages after upgrading to WooCommerce 2.1.

Why did you replace shortcodes with endpoints?

It makes installing WooCommerce easier and less prone to user error. With the pages and endpoints, we had to install the page, then set the content, then ensure WooCommerce knew where these pages were via settings.

If a user edited, moved or deleted one of these pages, it risked breaking the site. Endpoints remove that risk.

Account page endpoints ↑ Back to Top

The following endpoints are used for account-related functionality and are appended to the URL of the my-account page:

  1. View order – /view-order/{ORDER_ID}
  2. Edit account (and change password – /edit-account/
  3. Edit address – /edit-address/{ADDRESS_TYPE}
  4. Lost password – /lost-password/
  5. Logout – /customer-logout/

Checkout page endpoints ↑ Back to Top

The following endpoints are used for checkout-related functionality and are appended to the URL of the checkout page:

  1. Pay page – /order-pay/{ORDER_ID}
  2. Order received (thanks) – /order-received/
  3. Add payment method – /add-payment-method/

Customizing endpoint URLs ↑ Back to Top

The URL for each endpoint can be customized in settings. For account endpoints, go to WooCommerce > Settings > Accounts and edit the endpoint settings:

2014-02-26 at 14.19

For checkout endpoints, go to WooCommerce > Settings > Checkout and modify:

2014-02-26 at 14.20

Ensure that they are unique to avoid conflicts. If you encounter issues with 404s, go to Settings > Permalinks and save to flush the rewrite rules.

Using endpoints in menus ↑ Back to Top

If you want to include an endpoint in your menus, you need to use the Links section:

2014-02-26 at 14.26

Enter the full URL to the endpoint and then insert that into your menu.

Remember that some endpoints, such as view-order, require an order ID to work. In general, we don’t recommend adding these endpoints to your menus. These pages can instead be accessed via the my-account page.

Using endpoints in Payment Gateway Plugins ↑ Back to Top

Developers would previously use get_permalink for the URL of the pay and thank you pages, and now should be using endpoints. WooCommerce provides helper functions in the order class for getting these URLs. They are:

$order->get_checkout_payment_url( $on_checkout = false );

and:

$order->get_checkout_order_received_url();

Gateways need to use these methods for full 2.1+ compatibility.

Troubleshooting ↑ Back to Top

Endpoints showing 404

1. If you see a 404 error, go to WordPress AdminSettings > Permalinks and Save. This ensures that rewrite rules for endpoints exist and are ready to be used.

2. If using an endpoint such as view-order, ensure that it specifies an order number. /view-order/ is invalid. /view-order/10/ is valid. These types of endpoints should not be in your navigation menus.

Endpoints are not working

On Windows servers, the web.config file may not be set correctly to allow for the endpoints to work correctly. In this case, clicking on endpoint links (e.g. /edit-account/ or /customer-logout/) may appear to do nothing except refresh the page. In order to resolve this, try simplifying the web.config file on your Windows server. Here’s a sample file configuration:

Pages direct to wrong place

Landing on the wrong page when clicking an endpoint URL is typically caused by incorrect settings. For example, clicking ‘Edit address’ on your account page takes you to the Shop page instead of the edit address form means you selected the wrong page in settings. Confirm that your pages are correctly configured and that a different page is used for each section.

Back to the top