@rollin
You can get custom fields values from WooCommerce orders by using the following code:
1 2 |
$order_id = 123; // Change this to the ID of the order you want to retrieve $order = wc_get_order($order_id); |
1
|
$custom_field_value = $order->get_meta('custom_field_name'); |
Replace custom_field_name
with the name of the custom field you want to retrieve.
1 2 3 4 5 6 |
$custom_fields = $order->get_meta_data(); foreach ($custom_fields as $field) { $field_name = $field->key; $field_value = $field->value; // Do something with the custom field name and value } |
This code snippet will allow you to retrieve custom field values from WooCommerce orders in WordPress.