-
Notifications
You must be signed in to change notification settings - Fork 7
Epic/subscription membership sync #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One oddity I've noticed while looking at the event log: when a new subscription is made on a node site and synchronized to the hub site, two newspack_node_subscription_changed are created. The only difference between the events is that one of them will have a products key in the JSON payload.
|
Thank you so much for the reviews @adekbadek I've addressed the issues on the first one. Let's take it step by step. Once that is ok, I'll move to the next one |
|
Actually I went ahead and replied at all the other comments |
Add/subscriptions backfillers
Add/membership plan updated
Revert "Revert "fix(memberships-sync): handle active subs from other …
* Revert "feat(admin): subscriptions view" This reverts commit cb5bcb7. * Revert "feat: remove hub's subscriptions and orders" This reverts commit e234425. * feat: remove api requests from woo item changed * feat: add backfillers for order and subscription_changed * feat: add user subscriptions metadata * fix: ensure assoc array when processing webhook data * feat: add membership plan updated event and backfiller * feat: add subscription products to woo central dashboard * fix: remove duplicate listeners
# [2.2.0-alpha.1](v2.1.0...v2.2.0-alpha.1) (2024-09-20) ### Bug Fixes * **sync:** use `newspack_esp_sync_contact` filter for the `network_registration_site` field ([#132](#132)) ([3755d07](3755d07)) ### Features * subscriptions and memberships sync reimplementation ([#122](#122)) ([04fc845](04fc845))
* Epic/subscription membership sync (#122) * Revert "fix(memberships-sync): handle active subs from other nodes (#114)" This reverts commit 97f9a58. * Revert "feat(admin): subscriptions view" This reverts commit cb5bcb7. * Revert "feat: remove hub's subscriptions and orders" This reverts commit e234425. * feat: remove api requests from woo item changed * feat: add backfillers for order and subscription_changed * feat: add user subscriptions metadata * fix: ensure assoc array when processing webhook data * feat: add product id in the array keys * feat: add membership plan updated event and backfiller * feat: add product id to array jeys * feat: add subscription products to woo central dashboard * fix: remove duplicate listeners * Revert "Revert "fix(memberships-sync): handle active subs from other nodes (#114)"" This reverts commit 4acd965. * remove merge leftovers * fix: fix constant name * Revert "fix(memberships-sync): handle active subs from other nodes (#114)" This reverts commit 97f9a58. * feat: handle active subs in other sites when cancelling memberships * feat: limit subscription purchase for user with network membership * chore: remove unused file * Update tests/unit-tests/test-subscription-integration.php Co-authored-by: Adam Cassis <adam@adamcassis.com> * tests: readability * fix: prevent the same note being added multiple times --------- Co-authored-by: Adam Cassis <adam@adamcassis.com>
This epic refactors the strategy to check for users' subscriptions across the network, as well as recovering the Woo centralized data based on sync events.
I did this on a series of chained PRs to make it easier to parse. They need to be reviewed and merged in order into the Epic branch. Last step is to merge this epic branch into trunk.
In this epic branch, we revert #114, cb5bcb7 and e234425, and do a little fix to ensure the data is always parsed the same way (9140a8e)
PRs to be merged in order
1: #123
This simply creates backfillers for the existing Woo events and creates a user meta where we store the user's network subscriptions.
Testing:
wp newspack-network data-backfill newspack_node_subscription_changedandwp newspack-network data-backfill newspack_node_order_changed. Test it inverboseand normal modeswp newspack-network process-webhooksin the Node to speed syncing up)get_user_meta( $user_id, '_newspack_network_subscriptions', true);2: #124
This PR creates the
membership_plan_updatedeventTesting
wp newspack-network data-backfill newspack_network_membership_plan_updatedprocess-webhooksto send events to the hub)get_option( 'newspack_network_membership_plans' );membership_plan_updatedeventALTERNATIVE
#134
The above PR brings back #114 .
We can merge it and release. Then we'll have all the new events. After they are deployed and all the backfills are executed. We can revert #114 again and proceed with the remaining PRs
END OF ALTERNATIVE
3: #125
This is a re-implementation of #114
Testing:
wp newspack-network process-webhooksin the node to sync events to the Hub4: #126
This is a re-implementation of #112
Testing:
wp newspack-network process-webhooksandwp newspack-network sync-allin the Nodenewspack_network_membership_plan_updatedevents in the Event log for both the plan in the hub and the plan in the nodenewspack_network_membership_plansoption populated in both sites (this is what we tested in Add/membership plan updated #124