• Resolved guardiano78

    (@guardiano78)


    Hello,
    I created a shortcode:

    function check_warranty()
    {
    	echo 'please code here';
    }
    add_shortcode('check_warranty', 'check_warranty');

    In my account page, I added a custom tab using this code:

    
    add_action( 'init', 'register_new_item_endpoint');
    function register_new_item_endpoint() {
    	add_rewrite_endpoint( 'warranty-check', EP_ROOT | EP_PAGES );
    }
    
    add_filter( 'query_vars', 'new_item_query_vars' );
    function new_item_query_vars( $vars ) {
    
    	$vars[] = 'warranty-check';
    	return $vars;
    }
    
    add_filter( 'woocommerce_account_menu_items', 'add_new_item_tab' );
    function add_new_item_tab( $items ) {
    
    	$items['warranty-check'] = 'Warranty Check';
    	return $items;
    }
    
    add_action( 'woocommerce_account_warranty-check_endpoint', 'add_new_item_content' );
    function add_new_item_content() {
    	echo do_shortcode( ' [check_warranty] ' );
    }
    

    I created a page with slug “warranty-check” and I put in the shortcode:
    [check_warranty]

    In My Account page, when I click on “Warranty Check” tab, is loaded the page created, without my account left sidebar.
    What am I doing wrong?
    Thank you.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Woocommerce: add content to custom endpoint’ is closed to new replies.