NO BUG: WooCommerce: billing phone number as custom dynamic data tag

Hi,

I followed these tutorials - Dynamic Data – Bricks Academy and Create Your Own Dynamic Data Tag – Bricks Academy

I couldn’t successfully create a dynamic tag to query woocommerce billing phone number.

Another question is, must the user role be customer? Because there are other roles with access to woocommerce shop and also have woocommerce billing info set.

Hi,
Thanks so much for your report!

Would you please show the custom code you are using?

Best regards,
timmse

The filter

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

function get_user_billing_phone_number() {
    // Get the current user's ID
    $user_id = get_current_user_id();

    // Check if the user is logged in
    if ( $user_id ) {
        // Get the user's billing phone number
        $billing_phone = get_user_meta( $user_id, 'billing_phone', true );

        // Return the billing phone number
        return $billing_phone;
    }

    // If the user is not logged in or the phone number is not available, return an empty string
    return '';
}

And then attempted this to out the info

{echo:get_user_billing_phone_number()}

PS: @bricksultimate
You guys dynamic tag to query customer billing info ain’t working too.

Just tested and it is working

1 Like

?

Could this the case?

I think it is rather because get_user_billing_phone_number() is missing in the bricks/code/echo_function_names filter :thinking:

add_filter( 'bricks/code/echo_function_names', function() {
    return [
        'get_user_billing_phone_number',
        'get_user_meta', // Allow calling get_user_meta() function,
    ];
} );
1 Like

@bricksultimate

Your ordered item name (that is to display the name of the product ordered) not working.

Open support ticket for any issue.