How to change the name of the account and add the full name of the buyer?
-
Hello. How to change the name of the account and add the full name of the buyer? Details on screen.
https://hkar.ru/15hqq
-
Hi @antickas,
You can change the document’s title and customize the billing and shipping address in two ways:
- Using the Professional extension: This adds a setting to customize the documents’ title, and another settings to customize both billing and shipping address, using placeholders.
- Using the free version: You can also change the documents’ title in the free version through the filter hooks available in the plugin (check this example). To customize your customer’s addresses, you can use the PDF template action hooks, e.g. the
wpo_wcpdf_after_billing_addressaction hook. You can get the customer’s billing full name like this$order->get_formatted_billing_full_name()
Thanks, the title has been changed. The name of the buyer does not come out to add. Am I doing right?
add_action( 'wpo_wcpdf_after_billing_address', 'wpo_wcpdf_get_formatted_billing_full_name', 10, 2 ); function wpo_wcpdf_get_formatted_billing_full_name ($document_type, $order) { ?> <tr class="get_formatted_billing_full_name"> <th>ФИО:</th> <td><?php echo $order->get_formatted_billing_full_name() ; ?></td> </tr> <?php }Try with this code snippet instead:
/** * Display full billing name after the billing address */ add_action( 'wpo_wcpdf_after_billing_address', function( $document_type, $order ){ echo '<div class="billing-full-name">ФИО: ' . $order->get_formatted_billing_full_name() . '</div>'; }, 10, 2 );Does not work. Displays only the abbreviation ФИО, but not the last name, first name, patronymic of the buyer.
ТОВАРНЫЙ ЧЕК Пункт приема -выдачи (до 30 кг), ул. Речмедина 29 Андрушевка (Погребищенский р-н) Винницкая ФИО: mail@gmail.com 0971111111order information:
last name: Романов
first name: Дмитрий
patronymic: Владимирович`Instead of ФИО it should be Романов Дмитрий Владимирович
Do you maybe have setting up the last name, first name, and patronymic name as custom checkout fields? By default, WooCommerce only provide fields for last and first names, so if you have set up those fields as custom fields, you’ll need to use the actual order meta keys for those fields, like this:
/** * Display full billing name after the billing address */ add_action( 'wpo_wcpdf_after_billing_address', function( $document_type, $order ){ if ( $order && $document_type == 'invoice' ) { $full_name = array( 'last_name' => $order->get_meta( 'custom_last_name' ), // your actual meta key for last name goes here 'first_name' => $order->get_meta( 'custom_first_name' ), // your actual meta key for first name goes here 'patronymic_name' => $order->get_meta( 'custom_patronymic_name' ), // your actual meta key for patronymic name goes here ); $full_name = implode( ' ', $full_name ); echo '<div class="billing-full-name">ФИО: ' . $full_name . '</div>'; } }, 10, 2 );Thank you, it works.
I’m glad to hear that it worked!
If you don’t mind and have the time, do you think you could leave us a review?
Thanks in advance and all the best with your store!
The topic ‘How to change the name of the account and add the full name of the buyer?’ is closed to new replies.