Fany_VanDaal

Export jména a příjmení z objednávek jako jedna položak

Mar 23rd, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. // export jména a příjmení z woocommerce jako jedna položka
  2. function jmenoaprijmeni( $order_id ) {
  3.   $order = new WC_Order( $order_id );
  4.   $user_id = $order->get_user_id();
  5.   // Check if the user id is not false.
  6.   if ( $user_id ) {
  7.     $fname = get_user_meta( $user_id, 'billing_first_name', true );
  8.     $lname = get_user_meta( $user_id, 'billing_last_name', true );
  9.     // In case customer info does not have 'first name'
  10.     // get the name from the order billing info.
  11.     if ( ! $fname ) {
  12.       $fname = $order->get_billing_first_name();
  13.     }
  14.     // In case customer info does not have 'last name'
  15.     // get the name from the order billing info.
  16.     if ( ! $lname ) {
  17.       $lname = $order->get_billing_last_name();
  18.     }
  19.   } else {
  20.     // Get the billing first name
  21.     $fname = $order->get_billing_first_name();
  22.     // Get the billing last name
  23.     $lname = $order->get_billing_last_name();
  24.   }
  25.   $name = $fname . " " . $lname;
  26.   return $name;
  27. }
Add Comment
Please, Sign In to add comment