Skip to content

Commit 0b2567e

Browse files
authored
Create add-user-meta-to-wc-pip-invoices.php
1 parent 1ce02af commit 0b2567e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
// Modified from: https://github.com/godaddy-wordpress/wc-plugins-snippets/blob/master/woocommerce-print-invoices-packing-lists/sample-add-custom-meta.php
3+
function mb_add_user_meta_to_wc_pip_invoices( $type, $action, $document, $order ): void {
4+
// Uncomment if you want to only add this to invoices
5+
// if ( 'invoice' !== $document_type ) {
6+
// return;
7+
// }
8+
9+
$user_id = $order->get_user_id();
10+
if ( ! $user_id ) {
11+
return;
12+
}
13+
14+
$args = [
15+
'object_type' => 'user',
16+
'storage_type' => 'custom_table',
17+
'table' => 'creaktor_users',
18+
];
19+
20+
// For billing VAT number.
21+
$billing_vat_number = rwmb_meta( 'user_billing_vat_number', $args, $user_id );
22+
echo $billing_vat_number;
23+
24+
// For shipping VAT number.
25+
$shipping_vat_number = rwmb_meta( 'user_shipping_vat_number', $args, $user_id );
26+
echo $shipping_vat_number;
27+
}
28+
29+
add_action( 'wc_pip_after_customer_addresses', 'mb_add_user_meta_to_wc_pip_invoices', 10, 4 );

0 commit comments

Comments
 (0)