How to edit functions.php in child-theme probably?

This topic has 2 replies, 2 voices, and was last updated 3 years, 3 months ago ago by Olga Barlow

  • Avatar: keith
    keith
    Participant
    August 9, 2021 at 10:58

    I would like to add custom endpoint of woocommerce by inserting this code in functions.php

    /**
     * 1. Register new endpoint slug to use for My Account page
     */
    
    /**
     * @important-note	Resave Permalinks or it will give 404 error
     */
    function ts_custom_add_premium_support_endpoint() {
        add_rewrite_endpoint( 'premium-support', EP_ROOT | EP_PAGES );
    }
      
    add_action( 'init', 'ts_custom_add_premium_support_endpoint' );
      
      
    /**
     * 2. Add new query var
     */
      
    function ts_custom_premium_support_query_vars( $vars ) {
        $vars[] = 'premium-support';
        return $vars;
    }
      
    add_filter( 'woocommerce_get_query_vars', 'ts_custom_premium_support_query_vars', 0 );
      
      
    /**
     * 3. Insert the new endpoint into the My Account menu
     */
      
    function ts_custom_add_premium_support_link_my_account( $items ) {
        $items['premium-support'] = 'Premium Support';
        return $items;
    }
      
    add_filter( 'woocommerce_account_menu_items', 'ts_custom_add_premium_support_link_my_account' );
      
      
    /**
     * 4. Add content to the new endpoint
     */
      
    function ts_custom_premium_support_content() {
    	echo '<h3>Premium WooCommerce Support</h3><p>Welcome to the WooCommerce support area. As a premium customer, you can submit a ticket should you have any WooCommerce issues with your website, snippets or customization. <i>Please contact your theme/plugin developer for theme/plugin-related support.</i></p>';
    	
    	echo do_shortcode( ' /* your shortcode here */ ' );
    }
    
    /**
     * @important-note	"add_action" must follow 'woocommerce_account_{your-endpoint-slug}_endpoint' format
     */
    add_action( 'woocommerce_account_premium-support_endpoint', 'ts_custom_premium_support_content' );

    However, after I inserted the code into functions.php, the website stop working.

    I would like to know how should this code be put into functions.php probably?
    Thanks

    1 Answer
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    August 9, 2021 at 17:22

    Hello,

    Sorry but we are not responsible for the third-party code. Contact the author of that code to get help. We are able to help you with built-in options.

    Regards

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.