Order Metadata
When processing an order, the plugin stores phone numbers in international format (E.164) in different locations depending on the checkout type.
Order Fields
Section titled “Order Fields”Classic Checkout
Section titled “Classic Checkout”| Field | Method | Description |
|---|---|---|
billing_phone | $order->get_billing_phone() | Billing phone in international format |
_<field_id> | $order->get_meta('_<field_id>') | Additional phone fields (order meta with _ prefix) |
Block Checkout
Section titled “Block Checkout”| Field | Method | Description |
|---|---|---|
billing_phone | $order->get_billing_phone() | Billing phone in international format |
shipping_phone | $order->get_shipping_phone() | Shipping phone in international format |
_<field_id> | $order->get_meta('_<field_id>') | Additional phone fields (order meta with _ prefix) |
Reading Data Examples
Section titled “Reading Data Examples”Getting Phone from an Order
Section titled “Getting Phone from an Order”$order = wc_get_order( $order_id );
// Billing phone (both classic and block checkout)$billing_phone = $order->get_billing_phone();// Result: "+420607123456"
// Shipping phone (block checkout only)$shipping_phone = $order->get_shipping_phone();
// Additional phone field (e.g. company_phone)$company_phone = $order->get_meta( '_company_phone' );Getting Phone from a User Profile
Section titled “Getting Phone from a User Profile”$customer = new WC_Customer( $user_id );
// Billing phone$billing_phone = $customer->get_billing_phone();
// Shipping phone (updated only from block checkout)$shipping_phone = $customer->get_shipping_phone();Phone Number Format
Section titled “Phone Number Format”The plugin stores numbers in E.164 format:
| Input | Output |
|---|---|
607 123 456 (with CZ dial code) | +420607123456 |
+49 170 1234567 | +491701234567 |
(212) 555-1234 (with US dial code) | +12125551234 |
Where to Place Your Code
Section titled “Where to Place Your Code”You can add custom functions either in your child theme’s functions.php or use the Code Snippets plugin.