feat: integrate custom OData endpoints for stock and price sync
Replace broken itemLedgerEntries approach with custom ItemByLocation OData V4 endpoint for location-specific stock. Add ListaPrecios endpoint for price list sync (B2C regular, B2C_OF sale price) with filters for active status and all-customers assignment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,9 @@ class WBC_Admin {
|
||||
register_setting( 'wbc_connection', 'wbc_company_id', array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
) );
|
||||
register_setting( 'wbc_connection', 'wbc_company_name', array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
) );
|
||||
|
||||
// Sync settings (own group)
|
||||
register_setting( 'wbc_sync', 'wbc_sync_frequency', array(
|
||||
@@ -71,6 +74,12 @@ class WBC_Admin {
|
||||
register_setting( 'wbc_sync', 'wbc_location_code', array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
) );
|
||||
register_setting( 'wbc_sync', 'wbc_regular_price_list', array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
) );
|
||||
register_setting( 'wbc_sync', 'wbc_sale_price_list', array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
) );
|
||||
|
||||
// Order settings (own group)
|
||||
register_setting( 'wbc_orders', 'wbc_enable_order_sync', array(
|
||||
|
||||
@@ -126,6 +126,19 @@ $tabs = array(
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="wbc_company_name"><?php esc_html_e( 'Company Name', 'woo-business-central' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" id="wbc_company_name" name="wbc_company_name"
|
||||
value="<?php echo esc_attr( get_option( 'wbc_company_name', '' ) ); ?>"
|
||||
class="regular-text" placeholder="e.g. TRADE FORCE BRANS" />
|
||||
<p class="description">
|
||||
<?php esc_html_e( 'Exact company name in Business Central (used for custom OData endpoints like ItemByLocation and ListaPrecios).', 'woo-business-central' ); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p class="submit">
|
||||
@@ -197,7 +210,33 @@ $tabs = array(
|
||||
<?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' ); ?>
|
||||
<?php esc_html_e( 'Uses the custom ItemByLocation OData endpoint. Requires Company Name to be set in Connection settings.', 'woo-business-central' ); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="wbc_regular_price_list"><?php esc_html_e( 'Regular Price List Code', 'woo-business-central' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" id="wbc_regular_price_list" name="wbc_regular_price_list"
|
||||
value="<?php echo esc_attr( get_option( 'wbc_regular_price_list', '' ) ); ?>"
|
||||
class="regular-text" placeholder="e.g. B2C" />
|
||||
<p class="description">
|
||||
<?php esc_html_e( 'BC price list code for WooCommerce regular price. Leave empty to use item unit price.', 'woo-business-central' ); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="wbc_sale_price_list"><?php esc_html_e( 'Sale Price List Code', 'woo-business-central' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" id="wbc_sale_price_list" name="wbc_sale_price_list"
|
||||
value="<?php echo esc_attr( get_option( 'wbc_sale_price_list', '' ) ); ?>"
|
||||
class="regular-text" placeholder="e.g. B2C_OF" />
|
||||
<p class="description">
|
||||
<?php esc_html_e( 'BC price list code for WooCommerce sale price. Leave empty to skip sale price sync.', 'woo-business-central' ); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user