Fany_VanDaal icon

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

Fany_VanDaal | PRO | 03/23/20 01:17:40 PM UTC | 0 ⭐ | 406 👁️ | Never ⏰ | []
PHP |

970 B

|

None

|

0 👍

/

0 👎

// 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;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎