In WooCommerce v3.2.6 and WordPress 4.9.1 I added an endpoint to the WooCommerce myaccount area (view-subscription):
function my_custom_endpoints() {
add_rewrite_endpoint( 'view-subscription', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'my_custom_endpoints' );
function my_custom_query_vars( $vars ) {
$vars[] = 'view-subscription';
return $vars;
}
add_filter( 'query_vars', 'my_custom_query_vars', 0 );
function view_subscription_endpoint_content() {
include get_template_directory().'/woocommerce/myaccount/view-subscription.php';
}
add_action( 'woocommerce_account_view-subscription_endpoint', 'view_subscription_endpoint_content' );
See endpoint worked but I need to pass the ID of a subscription (a post type) to the endpoint. Please guide how to do this
for example
myaccount/view-order/21313 - Displays details of order #21313
myaccount/view-subscription/35464 - I want this to display the details of the subscription post #35464.
Above URL` myaccount/view-subscription/35464 `, the view-subscription.php template is loading, but what is the best way to access the ID, 35464, from the URL? What's the right way to access these