feat: WooCommerce-first sync + location code filter

Reversed the product sync direction: instead of pulling all 60k+ items
from BC and matching against WooCommerce (600+ paginated API calls that
timeout), now iterates the ~100 WooCommerce products and queries BC for
each one by GTIN/item number (1-2 API calls per product).

Added Location Code setting (e.g. "ICP") to filter stock by BC location.
Uses Item Ledger Entries endpoint to sum per-location stock. Falls back
to total inventory if the endpoint is unavailable.

Also registered wbc_location_code in sync settings group and uninstall.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-17 10:26:02 +01:00
parent c06d6e4352
commit 2c36344932
4 changed files with 229 additions and 111 deletions

View File

@@ -68,6 +68,9 @@ class WBC_Admin {
register_setting( 'wbc_sync', 'wbc_enable_price_sync', array(
'sanitize_callback' => array( $this, 'sanitize_checkbox' ),
) );
register_setting( 'wbc_sync', 'wbc_location_code', array(
'sanitize_callback' => 'sanitize_text_field',
) );
// Order settings (own group)
register_setting( 'wbc_orders', 'wbc_enable_order_sync', array(