• I wanted to add the JVM WooCommerce Wishlist to the Storefront dashboard. Below you will find how to achieve this:

    Remember to visit permalink settings in wordpress after adding this code! It will update the rewrite for dashboard.

    add_filter ( 'woocommerce_account_menu_items', 'my_dashboard_wishlist' );
    function my_dashboard_wishlist( $menu_links ){
     
    	// we will hook "anyuniquetext123" later
    	$new = array( 'wishlist' => 'Wishlist' );
     
    	// array_slice() is good when you want to add an element between the other ones
    	$menu_links = array_slice( $menu_links, 0, 1, true ) 
    	+ $new 
    	+ array_slice( $menu_links, 1, NULL, true );
     
    	return $menu_links;
    }
    
    add_action( 'init', 'my_dashboard_wishlist_add_endpoint' );
    function my_dashboard_wishlist_add_endpoint() {
    
    	// remember to visit permalink settings in wordpress after adding this code
    	add_rewrite_endpoint( 'wishlist', EP_PAGES ); //EP_ROOT | 
    }
    
    add_action( 'woocommerce_account_wishlist_endpoint', 'my_dashboard_wishlist_endpoint_content' );
    function my_dashboard_wishlist_endpoint_content() { 
    
     	include locate_template( array('woocommerce/myaccount/my-wishlist.php')); 
    }

    Also do note the include locate_template file. This needs to be an template file containing the do_shortcode. Here is my template file for your reference.

    <?php
    /**
     * My Wishlist
     *
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly
    }
    
    ?>
    
    <p>
    	<?php echo apply_filters( 'woocommerce_my_account_my_wishlist_description', __( 'The following products are on your wishlist.', 'woocommerce' ) ); ?>
    </p>
    <header class="woocommerce-address-title title">
    <h3>Wishlist</h3>
    </header>
    
    <?php
    	echo do_shortcode('[jvm_woocommerce_wishlist]');
    ?>
    • This topic was modified 6 years, 9 months ago by opicron.
  • The topic ‘Storefront tutorial: Add JVM WooCommerce Wishlist to Dashboard’ is closed to new replies.