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

@@ -185,6 +185,22 @@ $tabs = array(
</label>
</td>
</tr>
<tr>
<th scope="row">
<label for="wbc_location_code"><?php esc_html_e( 'Location Code', 'woo-business-central' ); ?></label>
</th>
<td>
<input type="text" id="wbc_location_code" name="wbc_location_code"
value="<?php echo esc_attr( get_option( 'wbc_location_code', '' ) ); ?>"
class="regular-text" placeholder="e.g. ICP" />
<p class="description">
<?php esc_html_e( 'Optional. BC location code to filter stock by (e.g. "ICP"). Leave empty to use total inventory across all locations.', 'woo-business-central' ); ?>
</p>
<p class="description">
<?php esc_html_e( 'Note: Location-specific stock requires "Item Ledger Entries" to be available in your BC API. If unavailable, total inventory will be used as fallback.', 'woo-business-central' ); ?>
</p>
</td>
</tr>
</table>
<p class="submit">