Appending WooCommerce Endpoint Names To My account Page Titles in Bricks

Looking to add the WooCommerce endpoint names like “Orders”, “Downloads” after the WooCommerce ‘My account’ Page’s title text at the various endpoint URLs in Bricks?

Add the following in child theme‘s functions.php (w/o the opening PHP tag) or a code snippets plugin:

<?php 

function bl_get_endpoint_name(): string {
    if ( is_wc_endpoint_url( 'orders' ) ) {
        return ' - Orders';
    } elseif ( is_wc_endpoint_url( 'downloads' ) ) {
        return ' - Downloads';
    } elseif ( is_wc_endpoint_url( 'edit-address' ) ) {
        return ' - Addresses';
    } elseif ( is_wc_endpoint_url( 'edit-account' ) ) {
        return ' - Account details';
    } else {
        return '';
    }
}

Then set this for the Page title:

{post_title}{echo:bl_get_endpoint_name}

Reference

https://developer.woo.com/docs/woocommerce-endpoints/

Instant access to 390+ Bricks code tutorials with BricksLabs Pro

1 comment

Leave your comment