Created
September 30, 2021 08:55
-
-
Save ThienTranDuy/3bf337ed51fe105182ed6b537e0644a1 to your computer and use it in GitHub Desktop.
woocommerce - get order by order_id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get an instance of the WC_Order Object from the Order ID (if required) | |
$order = wc_get_order($order_id); | |
// Get the Customer ID (User ID) | |
$customer_id = $order->get_customer_id(); // Or $order->get_user_id(); | |
// Get the WP_User Object instance | |
$user = $order->get_user(); | |
// Get the WP_User roles and capabilities | |
$user_roles = $user->roles; | |
// Order | |
$yoopay_token = $this->get_option('yoopayToken'); | |
$order_total = $order->get_total(); | |
$payment_method = $order->get_payment_method(); | |
$customer_ip_address = $order->get_customer_ip_address(); | |
$customer_user_agent = $order->get_customer_user_agent(); | |
$currency = $order->get_currency(); | |
// customer | |
$billing_first_name = $order->get_billing_first_name(); | |
$billing_last_name = $order->get_billing_last_name(); | |
$billing_phone = $order->get_billing_phone(); | |
$billing_email = $order->get_billing_email(); | |
$billing_company = $order->get_billing_company(); | |
$billing_address_1 = $order->get_billing_address_1(); | |
$billing_address_2 = $order->get_billing_address_2(); | |
$billing_city = $order->get_billing_city(); | |
$billing_state = $order->get_billing_state(); | |
$billing_postcode = $order->get_billing_postcode(); | |
$billing_country = $order->get_billing_country(); | |
// Billing | |
$shipping_first_name = $order->get_shipping_first_name(); | |
$shipping_last_name = $order->get_shipping_last_name(); | |
$shipping_company = $order->get_shipping_company(); | |
$shipping_address_1 = $order->get_shipping_address_1(); | |
$shipping_address_2 = $order->get_shipping_address_2(); | |
$shipping_city = $order->get_shipping_city(); | |
$shipping_state = $order->get_shipping_state(); | |
$shipping_postcode = $order->get_shipping_postcode(); | |
$shipping_country = $order->get_shipping_country(); | |
// Order | |
echo "<br/>order_id: " . $order_id; | |
echo "<br/>yoopay_token: " . $yoopay_token; | |
echo "<br/>order_total: " . $order_total; | |
echo "<br/>currency: " . $currency; | |
echo "<br/>payment_method: " . $payment_method; | |
// customer | |
echo "<br/>customer_id: " . $customer_id; | |
echo "<br/>customer_ip_address: " . $customer_ip_address; | |
echo "<br/>customer_user_agent: " . $customer_user_agent; | |
// Billing | |
echo "<br/>billing_first_name: " . $billing_first_name; | |
echo "<br/>billing_last_name: " . $billing_last_name; | |
echo "<br/>billing_email: " . $billing_email; | |
echo "<br/>billing_phone: " . $billing_phone; | |
echo "<br/>billing_company: " . $billing_company; | |
echo "<br/>billing_address_1: " . $billing_address_1; | |
echo "<br/>billing_address_2: " . $billing_address_2; | |
echo "<br/>billing_city: " . $billing_city; | |
echo "<br/>billing_state: " . $billing_state; | |
echo "<br/>billing_postcode: " . $billing_postcode; | |
echo "<br/>billing_country: " . $billing_country; | |
// Shipping | |
echo "<br/>shipping_first_name: " . $shipping_first_name; | |
echo "<br/>shipping_last_name: " . $shipping_last_name; | |
echo "<br/>shipping_company: " . $shipping_company; | |
echo "<br/>shipping_address_1: " . $shipping_address_1; | |
echo "<br/>shipping_address_2: " . $shipping_address_2; | |
echo "<br/>shipping_city: " . $shipping_city; | |
echo "<br/>shipping_state: " . $shipping_state; | |
echo "<br/>shipping_postcode: " . $shipping_postcode; | |
echo "<br/>shipping_country: " . $shipping_country; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment