feat: customer lookup by NIF with default customer fallback

- Search BC customers by taxRegistrationNumber (NIF/CIF from _nif meta)
- If NIF found in BC, use that customer; if not, create with NIF
- If no NIF on order, use configurable default customer number
- Add Default Customer Number setting in Order Settings tab

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-17 16:06:42 +01:00
parent 6bc70afaf1
commit 782681b30f
3 changed files with 57 additions and 20 deletions

View File

@@ -94,6 +94,9 @@ class WBC_Admin {
register_setting( 'wbc_orders', 'wbc_shipping_item_number', array(
'sanitize_callback' => 'sanitize_text_field',
) );
register_setting( 'wbc_orders', 'wbc_default_customer_number', array(
'sanitize_callback' => 'sanitize_text_field',
) );
}
/**

View File

@@ -328,6 +328,19 @@ $tabs = array(
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="wbc_default_customer_number"><?php esc_html_e( 'Default Customer Number', 'woo-business-central' ); ?></label>
</th>
<td>
<input type="text" id="wbc_default_customer_number" name="wbc_default_customer_number"
value="<?php echo esc_attr( get_option( 'wbc_default_customer_number', '' ) ); ?>"
class="regular-text" />
<p class="description">
<?php esc_html_e( 'BC customer number to use for orders without NIF/CIF. Orders with NIF will look up or create a specific customer.', 'woo-business-central' ); ?>
</p>
</td>
</tr>
</table>
<p class="submit">