Skip to content

Keep WooSync's external store connections when WooCommerce is activated on the same site - #113

Draft
LiamSarsfield wants to merge 2 commits into
trunkfrom
fm/crm-woosync-local-store-registry
Draft

LiamSarsfield wants to merge 2 commits into
trunkfrom
fm/crm-woosync-local-store-registry

Conversation

@LiamSarsfield

@LiamSarsfield LiamSarsfield commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

This stops WooSync from dropping saved external store connections when the local WooCommerce store is added.

What

Woo_Sync::add_sync_site() now reads the saved connections first. Before, only a call without a site key read them; a call with one saved only the new site.

Why

get_active_sync_sites() adds the local store, key local, when WooCommerce is active and none is saved. On a site already syncing external stores, that call replaced the saved list: the external connections and their sync progress were lost, and those stores stopped syncing. Connecting another external store on a site running WooCommerce, before the local store was saved, lost the existing ones the same way.

It ships in the next release for every site, with no option to turn it off.

Testing

Automated (run):

  • New Sync_Sites_Test: with a synced external store saved, one test adds the local store directly, the other reads the connections with WooCommerce marked active. Both check the external store's entry is unchanged and fail without the fix.
  • WooSync suite (20 tests) and full suite (310 tests) pass; composer cs is clean.

By hand (not run):

  1. With WooCommerce inactive, connect an external store in CRM Settings → WooSync → Store Connections and let it sync.
  2. Activate WooCommerce and reload Store Connections.
  3. Both the External and Local stores are listed, with the external store's "Total Orders Imported" unchanged. Without the fix, only the Local store is listed.

Release Notes

  • Fix WooSync losing its external store connections when WooCommerce is activated on the same site

…ed on the same site

add_sync_site() read the saved store connections only when it had to
generate a site key. Given a key, it saved a list holding just the new
site. get_active_sync_sites() adds the local store that way when
WooCommerce is active and no local entry is saved, so every remote
connection and its sync progress was dropped and those stores stopped
syncing. Read the saved connections before adding in both cases.
…r the WooCommerce-active read

Woo Sync settings are also held in memory on the shared CRM settings
object, which the database reset between tests does not clear, so the
stores this test saved were still there for later tests. The test class
now puts the list back in tear_down().

A second test reads the connections with WooCommerce marked active, the
path that adds the local store on a live site, and checks the saved
remote store is kept.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant