8th Mar '24
/
1 comment

Appending WooCommerce Endpoint Names To My account Page Titles in Bricks

Updated on 13 Aug 2024

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}

Whitelist the bl_get_endpoint_name function.

Ex.:

<?php 

add_filter( 'bricks/code/echo_function_names', function() {
  return [
    'bl_get_endpoint_name'
  ];
} );

You should also add other functions (native or custom) being used in your Bricks instance besides bl_get_endpoint_name. This can be checked at Bricks → Settings → Custom code by clicking the Code review button.

More info on whitelisting can be found here.

Reference

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

Get access to all 630 Bricks code tutorials with BricksLabs Pro

1 comment

Leave your comment

 

Related Tutorials..

Pro
On Sale Products Bricks Query Loop

On Sale Products Bricks Query Loop

Looking to show only the WooCommerce products that are on sale in Bricks? Set up a query loop, enable the PHP query editor and paste:
Categories:
Pro
Out of Stock Ribbon for WooCommerce Products in Bricks

Out of Stock Ribbon for WooCommerce Products in Bricks

Show an “OUT OF STOCK” ribbon for WooCommerce products that are output via the Products element on listing pages.
Categories:
Pro
Top-Level Product Categories in Bricks

Top-Level Product Categories in Bricks

How to show top-level WooCommerce product categories in Bricks using a query loop.
Categories:
How To Remove the Featured Image from WooCommerce Product Gallery

How To Remove the Featured Image from WooCommerce Product Gallery

Product Gallery on single product pages in WordPress include the product's featured image by default. If you are looking to exclude it so only the…
Categories:
Pro
WooCommerce Products Live Search in Bricks

WooCommerce Products Live Search in Bricks

This Pro tutorial provides the steps to set up a live search for WooCommerce products in Bricks. Note: Bricks' live search works with any type…
Categories:
Pro
Product Attribute based Related Products Bricks Query Loop

Product Attribute based Related Products Bricks Query Loop

How to output products related by value of attribute(s) for the current product on single WooCommerce product pages.
Categories: