background img
Nov 30, 2018
237 Views
0 0

WooCommerce Endpoints

Written by

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

WooCommerce Endpoints are essentially an extra part of 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.

Also By default, the endpoints are already set up WooCommerce > Settings > Advanced the Page setup section.

Checkout WooCommerce Endpoints

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/
  4. Delete payment method – /delete-payment-method/
  5. Set the default payment method – /set-default-payment-method/

Account WooCommerce Endpoints

The URL of the /my-account page:

  1. Orders – /orders/
  2. View order – /view-order/{ORDER_ID}
  3. Downloads – /downloads/
  4. Edit account (and change password) – /edit-account/
  5. Addresses – /addresses/
  6. Payment methods – /payment-methods/
  7. Lost password – /lost-password/
  8. Logout – /customer-logout/

Customizing Endpoint URLs

The URL for each endpoint can be customized in WooCommerce > Settings > Advanced 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:

WooCommerce Endpoints

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.

Troubleshooting

Endpoints Showing 404

  1. If you see a 404 error, go to WordPress Admin > Settings > Permalinks and Save. Also, this ensures that rewrite rules for endpoints exist and are ready to use.
  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.

WooCommerce 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. Also, here’s a sample file configuration:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read, Execute, Script" />
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</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. Also, confirm that your pages are correctly configured and that a different page is used for each section.

Also, you can explore more places and about this function using the below link –

Reference – https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint.

Also Read,

Article Tags:
Article Categories:
WooCommerce

Leave a Reply

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


The maximum upload file size: 300 MB.
You can upload: image, audio, video, document, text, other.
Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded.