[Resolved] Display Woocommerce Endpoint Title in Header Element

Home Forums Support [Resolved] Display Woocommerce Endpoint Title in Header Element

Home Forums Support Display Woocommerce Endpoint Title in Header Element

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1043883
    Kim

    Hi there, I would like to add a custom header to the my account area of woocommerce and try to display the titel of the current woocommerce endpoint (like “Downloads” etc.). {{post_title}} does not work unfortunately, it only shows “My Account” on every site. Can you provide some help with this?

    BR and many thanks ๐Ÿ™‚

    #1044106
    David
    Staff
    Customer Support

    Hi there,

    hmmm would require custom development for another shortcode to do this, and Woo doesn’t make it easy – Try this:

    function db_display_current_endpoint() {
        if ( is_account_page() ) {
            $endpoint = WC()->query->get_current_endpoint();
            switch ($endpoint) {
                case "downloads":
                    $endpoint_title = "Downloads";
                    break;
                case "orders":
                    $endpoint_title = "Orders";
                    break;
                case "edit-address":
                    $endpoint_title = "Addresses";
                    break;
                case "edit-account":
                    $endpoint_title = "Account";
                    break;
                default:
                    $endpoint_title = "My Account";
                    break;         
            }
            ob_start();
            echo '<h2 class="endpoint-title">' . $endpoint_title . '</h2>';
            return ob_get_clean();
        }
    }
    
    add_shortcode( 'current_endpoint', 'db_display_current_endpoint' );

    This provides the [current_endpoint] shortcode

    You can edit the $endpoint_title variables to display a custom message.

    #1044843
    Kim

    AWESOME! Works perfectly ๐Ÿ™‚ Many thanks!

    #1045285
    David
    Staff
    Customer Support

    You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.