What are WooCommerce Endpoints and how to use them?

Endpoints are an extra part in the website URL that is detected to show different content when present.

For instance: You may have a ‘my record’ page displayed at URL yoursite.com/my-account. At the point when the endpoint ‘alter account’ is annexed to this URL, making it ‘yoursite.com/my-account/alter account’ then the Alter account page is displayed rather than the My record page. Woocommerce Support

This permits us to show diverse substance without the requirement for various pages and shortcodes, and diminishes the measure of content that should be introduced.

Endpoints are located at WooCommerce > Settings > Advanced.

Checkout endpoints

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

  • Pay page – /order-pay/{ORDER_ID}
  • Order received (thanks) – /order-received/
  • Add payment method – /add-payment-method/
  • Delete payment method – /delete-payment-method/
  • Set default payment method – /set-default-payment-method/

Account endpoints

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

  • Orders – /orders/
  • View order – /view-order/{ORDER_ID}
  • Downloads – /downloads/
  • Edit account (and change password) – /edit-account/
  • Addresses – /edit-address/
  • Payment methods – /payment-methods/
  • Lost password – /lost-password/
  • Logout – /customer-logout/

Customizing endpoint URLs

The URL for each endpoint can be customized inWooCommerce > Settings > Advanced in the Page setup section.

WooCommerce endpoints

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

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

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

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.

Leave a Reply

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