Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // export jména a příjmení z woocommerce jako jedna položka
- function jmenoaprijmeni( $order_id ) {
- $order = new WC_Order( $order_id );
- $user_id = $order->get_user_id();
- // Check if the user id is not false.
- if ( $user_id ) {
- $fname = get_user_meta( $user_id, 'billing_first_name', true );
- $lname = get_user_meta( $user_id, 'billing_last_name', true );
- // In case customer info does not have 'first name'
- // get the name from the order billing info.
- if ( ! $fname ) {
- $fname = $order->get_billing_first_name();
- }
- // In case customer info does not have 'last name'
- // get the name from the order billing info.
- if ( ! $lname ) {
- $lname = $order->get_billing_last_name();
- }
- } else {
- // Get the billing first name
- $fname = $order->get_billing_first_name();
- // Get the billing last name
- $lname = $order->get_billing_last_name();
- }
- $name = $fname . " " . $lname;
- return $name;
- }
Add Comment
Please, Sign In to add comment