Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add custom menu item and endpoint to WooCommerce my-account page
/* Add custom menu item and endpoint to WooCommerce My-Account page */
function my_custom_endpoints() {
add_rewrite_endpoint( 'refunds-returns', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'my_custom_endpoints' );
// so you can use is_wc_endpoint_url( 'refunds-returns' )
add_filter( 'woocommerce_get_query_vars', 'my_custom_woocommerce_query_vars', 0 );
function my_custom_woocommerce_query_vars( $vars ) {
$vars['refunds-returns'] = 'refunds-returns';
return $vars;
}
function my_custom_flush_rewrite_rules() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_custom_flush_rewrite_rules' );
function my_custom_my_account_menu_items( $items ) {
$new_item = array( 'refunds-returns' => __( 'Refunds & Returns', 'woocommerce' ) );
// add item in 2nd place
$items = array_slice($items, 0, 1, TRUE) + $new_item + array_slice($items, 1, NULL, TRUE);
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );
function my_custom_endpoint_content() {
wc_get_template( 'myaccount/refunds-returns.php');
}
add_action( 'woocommerce_account_refunds-returns_endpoint', 'my_custom_endpoint_content' );
@mrkapable007

This comment has been minimized.

Copy link

mrkapable007 commented Jul 6, 2019

Hi, thank you for this amazing code. would it be possible to show the refunded amount as store credit to the customer?
or would it be possible to allow the customer to be able to make a purchase using the refunded order amount?

Kindly assist.

@alhoseany

This comment has been minimized.

Copy link
Owner Author

alhoseany commented Jul 7, 2019

Hi,
Yes, this is possible. But this will require totally different code. If you would like a paid help you can hire me here:
https://app.codeable.io/tasks/new?preferredContractor=24124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.