Skip to content

Fix subscription renewal contents - #4078

Open
ukilla wants to merge 1 commit into
mainfrom
fix/subscription-renewal-contents
Open

ukilla wants to merge 1 commit into
mainfrom
fix/subscription-renewal-contents

Conversation

@ukilla

@ukilla ukilla commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Description

Subscription plugins create an order empty and add its items and totals afterwards, so the Purchase sent from woocommerce_new_order had no contents and a zero value. Woo Subscriptions, WP Swings Subscriptions and YITH Subscription all do this, each with a different save sequence.

Orders that have no items when woocommerce_new_order fires are now deferred and reported on shutdown from their persisted state, independent of the plugin that created them. Checkout orders have items at creation and are reported exactly as before. Orders still empty or deleted by the end of the request are skipped. Purchase tracking meta is still stripped when Subscriptions copies data onto renewal, resubscribe and parent orders, so stale flags cannot suppress the event.

Type of change

  • Fix (non-breaking change which fixes an issue)

Checklist

  • I have commented my code, particularly in hard-to-understand areas, if any.
  • I have confirmed that my changes do not introduce any new PHPCS warnings or errors.
  • I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors.
  • I followed general Pull Request best practices. Meta employees to follow this wiki.
  • I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes.
  • I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality.
  • I have updated or requested update to plugin documentations (if necessary). Not required for this fix.

Changelog entry

Fix missing product details in Purchase events for orders created by subscription plugins.

Test Plan

Tested with WooCommerce 11.1.0, HPOS enabled, Woo Subscriptions 8.2.0, WP Swings Subscriptions for WooCommerce 2.0.2 and YITH WooCommerce Subscription 4.17.0.

  1. With tracking enabled, create a renewal through each plugin's own code: wcs_create_renewal_order(), wcs_create_resubscribe_order(), a generated parent order, a renewal from a subscription carrying stale tracking meta, and a real woocommerce_scheduled_subscription_payment run; WP Swings' HPOS renewal scheduler; YITH's renew_order(). Capture the outgoing Purchase with pre_http_request.
  2. Verify each order produces one server Purchase whose content IDs, quantities, value, currency and order ID match the order, and that payment_complete() and two thank-you page loads add no further server event while reusing the same event ID.
  3. Place a normal checkout order and confirm the Purchase still fires at creation, unchanged.

@meta-cla meta-cla Bot added the CLA Signed label Oct 5, 2026
@ukilla
ukilla force-pushed the fix/subscription-renewal-contents branch 2 times, most recently from b722635 to 11d38c4 Compare October 5, 2026 13:02
@ukilla ukilla added the changelog: fix Took care of something that wasn't working. label Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

📦 Latest Plugin Build

Built at: 2026-11-05T10:26:02Z
Commit: c6549ab
Size: 1.9M

Download: Click here to download the plugin

To download: Click the link above → Scroll to bottom → Download "facebook-for-woocommerce" artifact

Subscription plugins save an empty order first and add its items and
totals afterwards, so the Purchase sent from woocommerce_new_order had
no contents and a zero value.

Defer orders that have no items at creation and report them at the end
of the request from their persisted state, whichever plugin created
them. Checkout orders are unchanged. Keep stripping Purchase tracking
meta from renewal, resubscribe and parent order copies so stale flags
on a subscription cannot suppress the event.
@vahidkay-meta
vahidkay-meta force-pushed the fix/subscription-renewal-contents branch from 11d38c4 to dbc0b1d Compare November 5, 2026 10:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: fix Took care of something that wasn't working. CLA Signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants