ETA > Tax ID on checkout
Any estimated time of arrival for being able to ask for tax ID on checkout?
Currently it only gathers EU VAT when location is in EU, but no option is available for extra EU countries.
Am I missing something?
I have a similar issue. In Italy we need fiscal code by law from end users (not the EU VAT code).
So I added this snippet.
I guess you could easily change it and customize it to your needs (the only limit is that it doesn't perform any check on the inserted data).
use \FluentCart\App\Models\Customer;
/* 1. Campo Codice Fiscale / P.IVA nel checkout -------------------------------------------------------------------------- */ add_filter('fluent_cart/checkout_page_name_fields_schema', function ($nameFields, $context) {$cart = $context['cart'] ?? null;
$cfPivaValue = '';
if ($cart && isset($cart->checkout_data['form_data']['billing_cf_piva'])) {
$cfPivaValue = $cart->checkout_data['form_data']['billing_cf_piva'];
}
$nameFields['billing_cf_piva'] = [
'name' => 'billing_cf_piva',
'id' => 'billing_cf_piva',
'type' => 'text',
'data-type' => 'text',
'required' => 'yes',
'placeholder' => esc_attr__('Inserisci il tuo codice fiscale o la Partita IVA *', 'giorgioluciani'),
'autocomplete'=> 'off',
'value' => $cfPivaValue,
'extra_atts' => []
];
return $nameFields;
}, 10, 2);
/* 2. Validazione obbligatoria -------------------------------------------------------------------------- */ add_filter('fluent_cart/checkout/validate_data', function ($errors, $args) {if (empty($args['data']['billing_cf_piva'])) {
$errors['billing_cf_piva']['required'] = __('Il Codice fiscale / Partita IVA Γ¨ obbligatorio', 'giorgioluciani');
}
return $errors;
}, 10, 2);
/* 3. Salvataggio nel customer meta (pulito e sicuro) -------------------------------------------------------------------------- */ add_action('fluent_cart/checkout/prepare_other_data', function($args){$order = $args['order'];
$data = $args['validated_data'];
$customer = $order->customer;
if (!$customer || empty($data['billing_cf_piva'])) {
return;
}
$cf_piva = sanitize_text_field($data['billing_cf_piva']);
$customer->updateMeta('billing_cf_piva', $cf_piva);
}, 10, 1);
/* 4. Widget nella pagina cliente -------------------------------------------------------------------------- */ add_filter('fluent_cart/widgets/customer', function ($widgets, $data) {if (empty($data['customer_id'])) {
return $widgets;
}
$customerId = (int) $data['customer_id'];
$customer = Customer::query()->find($customerId);
if (!$customer) {
return $widgets;
}
$cfPiva = $customer->getMeta('billing_cf_piva');
if (!$cfPiva) {
return $widgets;
}
$content = sprintf(
'<div style="border:1px solid #e5e7eb;border-radius:8px;padding:12px;background:#fff;margin-top:8px;">
<div style="font-weight:600;margin-bottom:4px;">Codice fiscale / Partita IVA</div>
<div style="font-family:monospace;font-size:13px;">%s</div>
</div>',
esc_html($cfPiva)
);
$widgets[] = [
'title' => __('Codice fiscale / Partita IVA', 'xxx'),
'sub_title' => __('Dati cliente', 'xxx'),
'type' => 'html',
'content' => $content
];
return $widgets;
}, 10, 2);
Giorgio LucianiΒ Thank you Giorgio!
I really appreciate this, and I'll definitely check this out :)
The team told me they are working for adding it on next updates (Just a General Tax ID field.): hopefully this is prior to 2026!
I'd really like to start using FluentCart heavily, but this kind of missing points (eg.: like manual orders not calculating taxes yet...) are a big burden for many that are not used to customize their stacks.
How has been your daily use so far in EU? Quite interested!
Jorge de los ReyesΒ Hello Jorge, so far so good, I'd say, apart for this issue.
Giorgio LucianiΒ thanks for sharing!
