• When using the WooCommerce email preview feature (WooCommerce > Settings > Emails > Preview), the SUBRE Product Subscription for Woo plugin throws critical PHP errors because no actual subscription or order data is available in that preview context.

    Examples A:

    File: includes/data.php
    Issue: new WC_DateTime(“@{$timestamp}”) is called with an empty $timestamp, causing Failed to parse time string (@).

    Missing check like:

    if ( empty( $timestamp ) ) return new WC_DateTime('now');

    or return null when no timestamp is provided.

    Examples B:

    File: includes/subscription-order.php (around line 862)
    Issue: $subscription->get_payment_method() is called on false when wc_get_order() returns false (because no order exists in preview mode).

    Missing check like:

    if ( $subscription && is_a( $subscription, 'WC_Order' ) ) {

    }

    • This topic was modified 7 months, 1 week ago by Patryk.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Critical errors when previewing WooCommerce emails (missing test data)’ is closed to new replies.