Documentation > Developers > Filter Examples > Adding a Collection List to the WooCommerce My Account Menu

Adding a Collection List to the WooCommerce My Account Menu

/**
 * Add custom end point
 */
add_action( 'init', function() {

	// Set your custom endpoint
	// This will be the part of the URL, where the client will be able to see a list of his/her collections eg. /my-account/my-collections
	$endpoint_name = 'my-collections';

	add_rewrite_endpoint( $endpoint_name, EP_PAGES );
});


/**
 * Add custom item to the "My Account" menu
 */
add_filter( 'woocommerce_account_menu_items', function( $items ) {

	// Set the position after which your custom menu item should appear.
	// By default the following menu items exist: dashboard, orders, downloads, edit-address, edit-account, customer-logout
	$appear_after = 'orders';

	// Set this to the same endpoint as you have above
	$endpoint_name = 'my-collections';

	// Name the menu item
	$menu_item_label = 'My Collections';

	$position = array_search( $appear_after, array_keys( $items ) ) + 1;
	$items = array_slice( $items, 0, $position, true ) + array( $endpoint_name => $menu_item_label ) + array_slice( $items, $position, count( $items ) - 1, true ) ;

	return $items;
});


/**
 * Add the content to your custom end point
 */
add_action( 'woocommerce_account_my-collections_endpoint', function() {
	?>
	<h3>My Collections</h3>
	<h4>Please approve the following collections:</h4>
	<?php echo do_shortcode( '[picu_list_collections current_user status="sent"]<p>No collections to approve.</p>[/picu_list_collections]' ); ?>
	<hr />

	<h4>You have already approved the following collections:</h4>
	<?php echo do_shortcode( '[picu_list_collections current_user status="approved"]<p>You do not have any approved collections.</p>[/picu_list_collections]' ); ?>
	<hr />

	<h4>Download your final images:</h4>
	<?php echo do_shortcode( '[picu_list_collections current_user status="delivered"]<p>Currenlty there are no downloads available.</p>[/picu_list_collections]' ); ?>
	<?php
});Code language: PHP (php)

Need help?

If you couldn’t find what you were looking for and need more assistance, please get in touch with us directly and we’re happy to help.