Repository: woocommerce/woocommerce (PHP)

Issue:
REST API orders GET with coupons has TypeError: preg_match Argument 2 must be of type string stdClass given abstract-wc-data.php:910
### Prerequisites

- [x] I have carried out troubleshooting steps and I believe I have found a bug.
- [x] I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

### Describe the bug

I can reproduce this in dev sandbox with a default theme and only WooCommerce active. I must set-up a set of Woo REST API keys and use Postman App to query GET `https://sandbox.local/wp-json/wc/v3/orders?include=56450&per_page=50&consumer_key=ck_REDACTED&consumer_secret=cs_REDACTED`

Klaviyo reported this 500 issue to me. From what I can tell it mostly affects older orders that contain a coupon line item. Indeed getting the coupon date_created is in the stack trace.

Noting here that the coupon in question has email addresses cached into the order item meta - has the per-customer restriction.

### Expected behavior

I expect the REST API request to work or result in an error message, not crash.

### Actual behavior

500 error / crash. Here's the details:

```
2025-05-28T17:59:44+00:00 Critical Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, stdClass given in /nas/content/live/REDACTED/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php:910  
Additional context
{
    "error": {
        "type": 1,
        "file": "/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php",
        "line": 910
    },
    "remote-logging": true,
    "backtrace": [
        "",
        "#0 /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php(910): preg_match('/^(\\d{4})-(\\d{2...', Object(stdClass), NULL)",
        "#1 /wp-content/plugins/woocommerce/includes/class-wc-coupon.php(596): WC_Data->set_date_prop('date_created', Object(stdClass))",
        "#2 /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php(799): WC_Coupon->set_date_created(Object(stdClass))",
        "#3 /wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php(303): WC_Data->set_props(Array)",
        "#4 [internal function]: WC_REST_Orders_V2_Controller->get_order_item_data(Object(WC_Order_Item_Coupon))",
        "#5 /wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php(477): array_map(Array, Array)",
        "#6 /wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php(574): WC_REST_Orders_V2_Controller->get_formatted_item_data(Object(Automattic\WooCommerce\Admin\Overrides\Order))",
        "#7 /wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-orders-controller.php(438): WC_REST_Orders_V2_Controller->prepare_object_for_response_core(Object(Automattic\WooCommerce\Admin\Overrides\Order), Object(WP_REST_Request))",
        "#8 /wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php(542): WC_REST_Orders_Controller->prepare_object_for_response_core(Object(Automattic\WooCommerce\Admin\Overrides\Order), Object(WP_REST_Request))",
        "#9 /wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-crud-controller.php(405): WC_REST_Orders_V2_Controller->prepare_object_for_response(Object(Automattic\WooCommerce\Admin\Overrides\Order), Object(WP_REST_Request))",
        "#10 /wp-includes/rest-api/class-wp-rest-server.php(1292): WC_REST_CRUD_Controller->get_items(Object(WP_REST_Request))",
        "#11 /wp-includes/rest-api/class-wp-rest-server.php(1125): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wc/v3/orders', Array, NULL)",
        "#12 /wp-includes/rest-api/class-wp-rest-server.php(439): WP_REST_Server->dispatch(Object(WP_REST_Request))",
        "#13 /wp-includes/rest-api.php(459): WP_REST_Server->serve_request('/wc/v3/orders')",
        "#14 /wp-includes/class-wp-hook.php(324): rest_api_loaded(Object(WP))",
        "#15 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)",
        "#16 /wp-includes/plugin.php(565): WP_Hook->do_action(Array)",
        "#17 /wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)",
        "#18 /wp-includes/class-wp.php(818): WP->parse_request('')",
        "#19 /wp-includes/functions.php(1342): WP->main('')",
        "#20 /wp-blog-header.php(16): wp()",
        "#21 /index.php(17): require('/nas/content/li...')",
        "#22 {main}",
        "thrown"
    ]
}
```

### Steps to reproduce

1. Setup a local sandbox with WooCommerce and order histories containing coupons
2. Using the open-source Postman App or otherwise, send a REST API request to the sandbox using the link in the description adjusted for your environment.
3. Request an order number for an order that has a coupon line item.
4. Observe the 500 response.

### WordPress Environment

<details>

<summary>WordPress Environment</summary>

`
### WordPress Environment ###

WordPress address (URL): https://sandbox.local
Site address (URL): https://sandbox.local
WC Version: 9.8.5
Legacy REST API Package Version: The Legacy REST API plugin is not installed on this site.
Action Scheduler Version: ✔ 3.9.2
Log Directory Writable: ✔
WP Version: 6.8.1
WP Multisite: –
WP Memory Limit: 512 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US
External object cache: –

### Server Environment ###

Server Info: nginx/1.27.5
PHP Version: 8.1.32
PHP Post Max Size: 8 MB
PHP Time Limit: 30
PHP Max Input Vars: 1000
cURL Version: 8.13.0
OpenSSL/3.5.0 (SecureTransport)

SUHOSIN Installed: –
MySQL Version: 9.3.0
Max Upload Size: 2 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

### Database ###

WC Database Version: 9.8.5
WC Database Prefix: fas1_
Total Database Size: 2026.66MB
Database Data Size: 1472.77MB
Database Index Size: 553.89MB
fas1_woocommerce_sessions: Data: 4.52MB + Index: 0.08MB + Engine InnoDB
fas1_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
fas1_woocommerce_order_items: Data: 30.56MB + Index: 7.52MB + Engine InnoDB
fas1_woocommerce_order_itemmeta: Data: 970.73MB + Index: 134.38MB + Engine InnoDB
fas1_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
fas1_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
fas1_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_actionscheduler_actions: Data: 0.02MB + Index: 0.13MB + Engine InnoDB
fas1_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_actionscheduler_logs: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_adtribes_my_conversions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_aiowps_events: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_aiowps_failed_logins: Data: 0.41MB + Index: 0.00MB + Engine InnoDB
fas1_aiowps_global_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_aiowps_login_activity: Data: 0.16MB + Index: 0.00MB + Engine InnoDB
fas1_aiowps_login_lockdown: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_aiowps_permanent_block: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_commentmeta: Data: 2.52MB + Index: 3.03MB + Engine InnoDB
fas1_comments: Data: 30.56MB + Index: 25.09MB + Engine InnoDB
fas1_e_events: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_e_notes: Data: 0.02MB + Index: 0.17MB + Engine InnoDB
fas1_e_notes_users_relations: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
fas1_e_submissions: Data: 0.02MB + Index: 0.27MB + Engine InnoDB
fas1_e_submissions_actions_log: Data: 0.02MB + Index: 0.11MB + Engine InnoDB
fas1_e_submissions_values: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_ewwwio_images: Data: 3.52MB + Index: 4.00MB + Engine InnoDB
fas1_ewwwio_queue: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_failed_jobs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_gf_draft_submissions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_gf_entry: Data: 0.45MB + Index: 0.13MB + Engine InnoDB
fas1_gf_entry_meta: Data: 2.52MB + Index: 2.22MB + Engine InnoDB
fas1_gf_entry_notes: Data: 0.36MB + Index: 0.14MB + Engine InnoDB
fas1_gf_form: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_gf_form_meta: Data: 0.17MB + Index: 0.00MB + Engine InnoDB
fas1_gf_form_revisions: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_gf_form_view: Data: 0.45MB + Index: 0.42MB + Engine InnoDB
fas1_gf_rest_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_image_compression_settings: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_itsec_opaque_tokens: Data: 14.59MB + Index: 13.64MB + Engine InnoDB
fas1_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_mailchimp_carts: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_newsletter: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_newsletter_emails: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_newsletter_sent: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_newsletter_stats: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_options: Data: 9.47MB + Index: 1.67MB + Engine InnoDB
fas1_pmxe_exports: Data: 0.22MB + Index: 0.00MB + Engine InnoDB
fas1_pmxe_google_cats: Data: 0.39MB + Index: 0.00MB + Engine InnoDB
fas1_pmxe_posts: Data: 2.52MB + Index: 0.00MB + Engine InnoDB
fas1_pmxe_templates: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_pmxi_files: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_pmxi_history: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_pmxi_images: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_pmxi_imports: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_pmxi_posts: Data: 0.13MB + Index: 0.11MB + Engine InnoDB
fas1_pmxi_templates: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_postmeta: Data: 177.73MB + Index: 163.47MB + Engine InnoDB
fas1_posts: Data: 15.38MB + Index: 9.06MB + Engine InnoDB
fas1_queue: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_revslider_css: Data: 0.13MB + Index: 0.00MB + Engine InnoDB
fas1_revslider_layer_animations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_revslider_navigations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_revslider_sliders: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_revslider_slides: Data: 0.08MB + Index: 0.00MB + Engine InnoDB
fas1_revslider_static_slides: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_searchwp_index: Data: 1.52MB + Index: 1.11MB + Engine InnoDB
fas1_searchwp_log: Data: 14.55MB + Index: 21.58MB + Engine InnoDB
fas1_searchwp_status: Data: 0.08MB + Index: 0.08MB + Engine InnoDB
fas1_searchwp_tokens: Data: 0.20MB + Index: 0.36MB + Engine InnoDB
fas1_smush_dir_images: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
fas1_snippets: Data: 0.06MB + Index: 0.03MB + Engine InnoDB
fas1_swp_cf: Data: 3.52MB + Index: 6.55MB + Engine InnoDB
fas1_swp_index: Data: 8.52MB + Index: 8.03MB + Engine InnoDB
fas1_swp_log: Data: 7.52MB + Index: 12.55MB + Engine InnoDB
fas1_swp_tax: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
fas1_swp_terms: Data: 1.52MB + Index: 3.55MB + Engine InnoDB
fas1_term_relationships: Data: 0.14MB + Index: 0.13MB + Engine InnoDB
fas1_term_taxonomy: Data: 0.13MB + Index: 0.06MB + Engine InnoDB
fas1_termmeta: Data: 0.11MB + Index: 0.11MB + Engine InnoDB
fas1_terms: Data: 0.08MB + Index: 0.09MB + Engine InnoDB
fas1_usermeta: Data: 60.59MB + Index: 59.19MB + Engine InnoDB
fas1_users: Data: 4.52MB + Index: 5.55MB + Engine InnoDB
fas1_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wc_customer_lookup: Data: 1.52MB + Index: 1.86MB + Engine InnoDB
fas1_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_wc_gpf_render_cache: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_wc_order_addresses: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
fas1_wc_order_coupon_lookup: Data: 1.52MB + Index: 0.69MB + Engine InnoDB
fas1_wc_order_operational_data: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_wc_order_product_lookup: Data: 12.52MB + Index: 14.06MB + Engine InnoDB
fas1_wc_order_stats: Data: 2.52MB + Index: 3.45MB + Engine InnoDB
fas1_wc_order_tax_lookup: Data: 0.09MB + Index: 0.09MB + Engine InnoDB
fas1_wc_orders: Data: 0.02MB + Index: 0.11MB + Engine InnoDB
fas1_wc_orders_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_wc_product_attributes_lookup: Data: 0.05MB + Index: 0.02MB + Engine InnoDB
fas1_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_wc_product_meta_lookup: Data: 0.14MB + Index: 0.33MB + Engine InnoDB
fas1_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_wcpdf_invoice_number: Data: 1.52MB + Index: 0.00MB + Engine InnoDB
fas1_wcpdf_packing_slip_number: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wfauditevents: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wfblockediplog: Data: 0.22MB + Index: 0.00MB + Engine InnoDB
fas1_wfblocks7: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
fas1_wfconfig: Data: 3.52MB + Index: 0.00MB + Engine InnoDB
fas1_wfcrawlers: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wffilechanges: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wffilemods: Data: 9.52MB + Index: 0.00MB + Engine InnoDB
fas1_wfhits: Data: 1.52MB + Index: 0.27MB + Engine InnoDB
fas1_wfhoover: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_wfissues: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
fas1_wfknownfilelist: Data: 7.52MB + Index: 0.00MB + Engine InnoDB
fas1_wflivetraffichuman: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_wflocs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wflogins: Data: 0.47MB + Index: 0.14MB + Engine InnoDB
fas1_wfls_2fa_secrets: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_wfls_role_counts: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wfls_settings: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wfnotifications: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wfpendingissues: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
fas1_wfreversecache: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wfsecurityevents: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wfsnipcache: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
fas1_wfstatus: Data: 0.23MB + Index: 0.14MB + Engine InnoDB
fas1_wftrafficrates: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wfwafconfig: Data: 2.52MB + Index: 0.00MB + Engine InnoDB
fas1_wfwaffailures: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_woocommerce_bundled_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_woocommerce_bundled_items: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_woocommerce_gpf_google_taxonomy: Data: 1.52MB + Index: 0.13MB + Engine InnoDB
fas1_wp_optimisation_sizes_info: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wpfm_backup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wpforms_entries: Data: 2.52MB + Index: 0.05MB + Engine InnoDB
fas1_wpforms_entry_fields: Data: 1.52MB + Index: 0.66MB + Engine InnoDB
fas1_wpforms_entry_meta: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_wpmailsmtp_debug_events: Data: 0.19MB + Index: 0.00MB + Engine InnoDB
fas1_wpmailsmtp_emails_log: Data: 41.56MB + Index: 15.61MB + Engine InnoDB
fas1_wpmailsmtp_tasks_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wt_iew_action_history: Data: 0.05MB + Index: 0.00MB + Engine InnoDB
fas1_wt_iew_cron: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wt_iew_ftp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_wt_iew_mapping_template: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
fas1_yith_wcan_cache: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
fas1_yith_wcwl: Data: 2.52MB + Index: 1.52MB + Engine InnoDB
fas1_yith_wcwl_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
fas1_yith_wcwl_lists: Data: 2.52MB + Index: 27.67MB + Engine InnoDB
fas1_yoast_indexable: Data: 1.52MB + Index: 0.48MB + Engine InnoDB
fas1_yoast_indexable_hierarchy: Data: 0.11MB + Index: 0.17MB + Engine InnoDB
fas1_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
fas1_yoast_primary_term: Data: 0.08MB + Index: 0.06MB + Engine InnoDB
fas1_yoast_prominent_words: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
fas1_yoast_seo_links: Data: 0.22MB + Index: 0.16MB + Engine InnoDB
fas1_yoast_seo_meta: Data: 0.45MB + Index: 0.00MB + Engine InnoDB

### Post Type Counts ###

acf-field: 130
acf-field-group: 20
adt_product_feed: 3
attachment: 2542
custom_css: 2
customize_changeset: 14
elementor_library: 1
ep-synonym: 1
nav_menu_item: 49
oembed_cache: 7
order_shipment: 3
page: 77
popup: 2
popup_theme: 8
post: 107
product: 653
product_variation: 181
revision: 45
shop_coupon: 59
shop_order_placehold: 31098
sidebar: 1
tablepress_table: 5
wafs: 1
wp_global_styles: 1
wp_navigation: 1
wpforms: 4
yith_wcan_preset: 1

### Security ###

Secure connection (HTTPS): ✔
Hide errors from visitors: ✔

### Active Plugins (3) ###

WooCommerce.com Update Manager: by Automattic – 1.0.3
WooCommerce: by Automattic – 9.8.5
WPMU DEV Dashboard: by WPMU DEV – 4.11.29

### Inactive Plugins (27) ###

Advanced Custom Fields PRO: by WP Engine – 6.4.2
Advanced Order Export For WooCommerce: by AlgolPlus – 4.0.2
Classic Editor: by WordPress Contributors – 1.6.7
Code Snippets: by Code Snippets Pro – 3.6.8
Elementor: by Elementor.com – 3.29.1
Gratisfaction- Loyalty Rewards Referral Birthday and Giveaway Program: by Appsmav – 4.5.1
Gravity Forms: by Gravity Forms – 2.9.8
Kadence WooCommerce Email Designer: by Kadence WP – 1.5.16
Klaviyo: by Klaviyo
Inc. – 3.5.0

PDF Invoices & Packing Slips for WooCommerce: by WP Overnight – 4.5.2
Product Feed PRO for WooCommerce: by AdTribes.io – 13.4.4.2
SearchWP: by SearchWP – 4.4.0
SearchWP WooCommerce Integration: by SearchWP – 1.4.0
Sequential Order Numbers for WooCommerce: by SkyVerge – 1.11.1
Simple Banner: by Ryan Petersen – 3.0.7
SiteOrigin Widgets Bundle: by SiteOrigin – 1.68.4
TablePress: by Tobias Bäthge – 3.1.3
User Switching: by John Blackbourn – 1.9.2
WooCommerce Extended Coupon Features FREE: by Soft79 – 3.3.9
WooCommerce FedEx Shipping: by WooCommerce – 4.4.0
WooCommerce Google Product Feed: by Ademti Software Ltd. – 11.0.19
WooCommerce Legacy REST API: by WooCommerce – 1.0.5
WooCommerce Purchase Order Payment Gateway: by WooCommerce – 1.5.4
WooCommerce Stripe Gateway: by Stripe – 9.5.2
WooCommerce USPS Shipping: by WooCommerce – 5.1.8
YITH WooCommerce Ajax Product Filter: by YITH – 5.10.0
YITH WooCommerce Wishlist Premium: by YITH – 4.1.0

### Settings ###

Legacy API Enabled: –
Force SSL: ✔
Currency: USD ($)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: bundle (bundle)
composite (composite)
external (external)
grouped (grouped)
simple (simple)
variable (variable)

Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)

Connected to WooCommerce.com: ✔
Enforce Approved Product Download Directories: –
HPOS feature enabled: ✔
Order datastore: Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore
HPOS data sync enabled: –

### Logging ###

Enabled: ✔
Handler: Automattic\WooCommerce\Internal\Admin\Logging\LogHandlerFileV2
Retention period: 30 days
Level threshold: –
Log directory size: 491 KB

### WC Pages ###

Shop base: #4 - /shop/
Cart: #5 - /cart/ -  Contains the woocommerce_cart shortcode
Checkout: #6 - /checkout/ -  Contains the woocommerce_checkout shortcode
My account: #7 - /my-account/ -  Contains the [woocommerce_my_account] shortcode
Terms and conditions: #14748 - /terms-conditions/

### Theme ###

Name: Twenty Twenty-Five
Version: 1.2
Author URL: https://wordpress.org
Child Theme: ❌ – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme
Theme type: Block theme
WooCommerce Support: ❌ Not declared

### Templates ###

Overrides: /wp-content/plugins/woocommerce/templates/block-notices/error.php
/wp-content/plugins/woocommerce/templates/block-notices/notice.php
/wp-content/plugins/woocommerce/templates/block-notices/success.php


### Admin ###

Enabled Features: activity-panels
analytics
product-block-editor
coupons
core-profiler
customize-store
customer-effort-score-tracks
import-products-task
experimental-fashion-sample-products
shipping-smart-defaults
shipping-setting-tour
homescreen
marketing
mobile-app-banner
onboarding
onboarding-tasks
pattern-toolkit-full-composability
product-custom-fields
remote-inbox-notifications
remote-free-extensions
payment-gateway-suggestions
printful
shipping-label-banner
subscriptions
store-alerts
transient-notices
woo-mobile-welcome
wc-pay-promotion
wc-pay-welcome-page
launch-your-store
add-to-cart-with-options-stepper-layout

Disabled Features: product-data-views
experimental-blocks
coming-soon-newsletter-template
minified-js
product-pre-publish-modal
settings
async-product-editor-category-field
product-editor-template-system
use-wp-horizon
blockified-add-to-cart

Daily Cron: ✔ Next scheduled: 2025-05-19 20:55:29 -06:00
Options: ✔
Notes: 10
Onboarding: completed

### Action Scheduler ###

Pending: 6
Oldest: 2025-05-20 20:39:08 -0600
Newest: 2025-05-29 13:58:51 -0600

Canceled: 4
Oldest: -0001-11-29 17:00:04 -0659
Newest: -0001-11-29 17:00:04 -0659


### Status report information ###

Generated at: 2025-05-29 15:01:43 -06:00
`

</details>


### Isolating the problem

- [x] I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
- [x] This bug happens with a default WordPress theme active, or [Storefront](https://woocommerce.com/products/storefront/).
- [x] I can reproduce this bug consistently using the steps above.



Fix (patch):
diff --git a/plugins/woocommerce/changelog/58700-wooplug-4457-rest-api-orders-get-with-coupons-has-typeerror-preg_match b/plugins/woocommerce/changelog/58700-wooplug-4457-rest-api-orders-get-with-coupons-has-typeerror-preg_match
new file mode 100644
index 0000000000000..a412a1794be17
--- /dev/null
+++ b/plugins/woocommerce/changelog/58700-wooplug-4457-rest-api-orders-get-with-coupons-has-typeerror-preg_match
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+Comment: Fixes a bug where listing Woo orders on the REST API will crash if the order has a coupon with a malformed date.
+
diff --git a/plugins/woocommerce/includes/abstracts/abstract-wc-data.php b/plugins/woocommerce/includes/abstracts/abstract-wc-data.php
index 8a1a143ef5836..f0025d46c665c 100644
--- a/plugins/woocommerce/includes/abstracts/abstract-wc-data.php
+++ b/plugins/woocommerce/includes/abstracts/abstract-wc-data.php
@@ -19,7 +19,8 @@
  *
  * Implemented by classes using the same CRUD(s) pattern.
  *
- * @version  2.6.0
+ * @since    2.6.0
+ * @version  10.2.0
  * @package  WooCommerce\Abstracts
  */
 abstract class WC_Data {
@@ -905,7 +906,7 @@ protected function set_date_prop( $prop, $value ) {
 			} elseif ( is_numeric( $value ) ) {
 				// Timestamps are handled as UTC timestamps in all cases.
 				$datetime = new WC_DateTime( "@{$value}", new DateTimeZone( 'UTC' ) );
-			} else {
+			} elseif ( is_string( $value ) ) {
 				// Strings are defined in local WP timezone. Convert to UTC.
 				if ( 1 === preg_match( '/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|((-|\+)\d{2}:\d{2}))$/', $value, $date_bits ) ) {
 					$offset    = ! empty( $date_bits[7] ) ? iso8601_timezone_to_offset( $date_bits[7] ) : wc_timezone_offset();
@@ -914,6 +915,9 @@ protected function set_date_prop( $prop, $value ) {
 					$timestamp = wc_string_to_timestamp( get_gmt_from_date( gmdate( 'Y-m-d H:i:s', wc_string_to_timestamp( $value ) ) ) );
 				}
 				$datetime = new WC_DateTime( "@{$timestamp}", new DateTimeZone( 'UTC' ) );
+			} else {
+				// If we get here, the value is not a valid date type.
+				$this->error( 'invalid_date', __( 'Invalid date provided.', 'woocommerce' ) );
 			}
 
 			// Set local timezone or offset.