inspirednz
inspirednz

Reputation: 5087

WooCommerce: Why is `get_billing_first_name()` returning full name?

I am making some changes to a WooCommerce order email template.

I'd like to address the customer by their first name. But the code I understand should do this is returning their full name.

The code I have is:

<p><?php printf( esc_html__( 'Hello %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>

It's my understanding the following is required to return the full name:

<p><?php printf( esc_html__( 'Hello %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() . ' ' . $order->get_billing_last_name() ) ); ?></p>

Can someone explain to me why I get the first and last name with the first code snippet above?

Does this mean the site in question is for some odd reason storing the first and last name in the billing_first_name value?

Upvotes: 1

Views: 1486

Answers (1)

inspirednz
inspirednz

Reputation: 5087

I discovered this issue was caused by the following:

A previous developer on the site had decided to disable the *_last_name fields, and changed the name of the *_first_name fields to "Full Name". The result was that all order names were in the *_first_name field.

Simple cause, with a simple solution.

Upvotes: 1

Related Questions