Tax code or VAT number, in the customer registration form
-
bitit
- Member
- Posts: 84
- Joined: Thu Jun 24, 2021 4:00 pm
- Phoenix Version:
- Has thanked: 1 time
- Been thanked: 3 times
Tax code or VAT number, in the customer registration form
Is there a way to request a tax code or VAT number in the customer registration form or guest checkout?
I thought about modifying the suburb module for this
Enrico
I thought about modifying the suburb module for this
Enrico
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
Re: Tax code or VAT number, in the customer registration form
app.php/addons/supporters_code/s04e03_c ... ta_modules is a pack of customer data modules, maybe something there would be a good basis for your requirement.
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Tax code or VAT number, in the customer registration form
Question is probably the closest, but is meant to be renamed before use.
There've probably been several people who have done this. Just none who contributed the working product back.
There've probably been several people who have done this. Just none who contributed the working product back.
-
bitit
- Member
- Posts: 84
- Joined: Thu Jun 24, 2021 4:00 pm
- Phoenix Version:
- Has thanked: 1 time
- Been thanked: 3 times
Re: Tax code or VAT number, in the customer registration form
department, with changing translations work fine; i have also try to create a new module with relative translation, but i have a error that not understand; maybe is just more complicate, but i have just try.
this is the error:
this is the code of cd_taxcode.php
this is the error:
Code: Select all
Uncaught Error: Undefined constant "ENTRY_DEPARTMENT" in /archivio/html/mysite.it/shoes/includes/modules/customer_data/cd_taxcode.php:87\nStack trace:\n#0 /archivio/html/mysite.it/shoes/templates/default/includes/pages/create_account.php(51): cd_taxcode->display_input()\n#1 /archivio/html/mysite.it/shoes/create_account.php(43): require('...')\n#2 {main}\n thrown in /archivio/html/mysite.it/shoes/includes/modules/customer_data/cd_taxcode.php on line 87, referer: http://localhost/mysite.it/shoes/this is the code of cd_taxcode.php
Code: Select all
class cd_taxdata extends abstract_customer_data_module {
const CONFIG_KEY_BASE = 'MODULE_CUSTOMER_DATA_TAXCODE_';
const PROVIDES = [ 'taxcode' ];
const REQUIRES = [ ];
public function install($parameter_key = null) {
$structure_query = $GLOBALS['db']->query("SHOW COLUMNS FROM address_book LIKE 'entry_taxcode'");
if (!mysqli_num_rows($structure_query)) {
$GLOBALS['db']->query("ALTER TABLE address_book ADD entry_taxcode VARCHAR(255)");
}
parent::install($parameter_key);
}
protected function get_parameters() {
return [
static::CONFIG_KEY_BASE . 'STATUS' => [
'title' => 'Enable tax code module',
'value' => 'True',
'desc' => 'Do you want to add the module to your shop?',
'set_func' => "Config::select_one(['True', 'False'], ",
],
static::CONFIG_KEY_BASE . 'GROUP' => [
'title' => 'Customer data group',
'value' => '4',
'desc' => 'In what group should this appear?',
'use_func' => 'customer_data_group::fetch_name',
'set_func' => 'Config::select_customer_data_group(',
],
static::CONFIG_KEY_BASE . 'REQUIRED' => [
'title' => 'Require tax code module (if enabled)',
'value' => 'False',
'desc' => 'Do you want the tax code to be required in customer registration?',
'set_func' => "Config::select_one(['True', 'False'], ",
],
static::CONFIG_KEY_BASE . 'MIN_LENGTH' => [
'title' => 'Minimum Length',
'value' => '3',
'desc' => 'Minimum length of tax code',
],
static::CONFIG_KEY_BASE . 'PAGES' => [
'title' => 'Pages',
'value' => 'address_book;checkout_new_address',
'desc' => 'On what pages should this appear?',
'set_func' => 'Customers::select_pages(',
'use_func' => 'abstract_module::list_exploded',
],
static::CONFIG_KEY_BASE . 'SORT_ORDER' => [
'title' => 'Sort Order',
'value' => '3400',
'desc' => 'Sort order of display. Lowest is displayed first.',
],
static::CONFIG_KEY_BASE . 'TEMPLATE' => [
'title' => 'Template',
'value' => 'includes/modules/customer_data/cd_whole_row_input.php',
'desc' => 'What template should be used to surround this input?',
],
];
}
public function get($field, &$customer_details) {
switch ($field) {
case 'taxcode':
if (!isset($customer_details[$field])) {
$customer_details[$field] = $customer_details['taxcode']
?? $customer_details['entry_taxcode'] ?? null;
}
return $customer_details[$field];
}
}
public function display_input($customer_details = null) {
$label_text = ENTRY_TAXCODE;
$input_id = 'inputTaxcode';
$input = new Input('taxcode', ['id' => $input_id, 'placeholder' => ENTRY_TAXCODE_TEXT]);
if (!empty($customer_details) && is_array($customer_details)) {
$input->set('value', $this->get('taxcode', $customer_details));
}
if ($this->is_required()) {
$input->require();
$input = "$input" . FORM_REQUIRED_INPUT;
}
include $GLOBALS['Template']->map(MODULE_CUSTOMER_DATA_TAXCODE_TEMPLATE);
}
public function process(&$customer_details) {
$customer_details['taxcode'] = Text::input($_POST['taxcode']);
if (strlen($customer_details['taxcode']) < MODULE_CUSTOMER_DATA_TAXCODE_MIN_LENGTH
&& ($this->is_required()
|| !empty($customer_details['taxcode'])
)
)
{
$GLOBALS['messageStack']->add_classed(
$GLOBALS['message_stack_area'] ?? 'customer_data',
sprintf(ENTRY_TAXCODE_ERROR, MODULE_CUSTOMER_DATA_TAXCODE_MIN_LENGTH));
return false;
}
return true;
}
public function build_db_values(&$db_tables, $customer_details, $table = 'both') {
Guarantor::guarantee_subarray($db_tables, 'address_book');
$db_tables['address_book']['entry_taxcode'] = $customer_details['taxcode'];
}
public function build_db_aliases(&$db_tables, $table = 'both') {
Guarantor::guarantee_subarray($db_tables, 'address_book');
$db_tables['address_book']['entry_taxcode'] = 'taxcode';
}
}
-
bitit
- Member
- Posts: 84
- Joined: Thu Jun 24, 2021 4:00 pm
- Phoenix Version:
- Has thanked: 1 time
- Been thanked: 3 times
Re: Tax code or VAT number, in the customer registration form
if i have success to create this module, this is should be the first step to create others two modules, 1 for italian electronic invoice, 2 for certificated mail
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Tax code or VAT number, in the customer registration form
Department exists at the address level. Do you want VAT at the address level or the customer level?
The Error is saying that you're missing from the language fileAre you sure that you're still getting that error? Changing line 87 to ENTRY_TAXCODE should have fixed it, and it looks like you already did that.
The Error is saying that you're missing from the language file
Code: Select all
const ENTRY_DEPARTMENT = 'Department';-
bitit
- Member
- Posts: 84
- Joined: Thu Jun 24, 2021 4:00 pm
- Phoenix Version:
- Has thanked: 1 time
- Been thanked: 3 times
Re: Tax code or VAT number, in the customer registration form
a cache problem, working fine, only change the first line from:
to
in attach the full package .
can i add to my addons?
Code: Select all
class cd_taxdata extends abstract_customer_data_module {Code: Select all
class cd_taxcode extends abstract_customer_data_module {can i add to my addons?
You do not have the required permissions to view the files attached to this post.
-
bitit
- Member
- Posts: 84
- Joined: Thu Jun 24, 2021 4:00 pm
- Phoenix Version:
- Has thanked: 1 time
- Been thanked: 3 times
Re: Tax code or VAT number, in the customer registration form
hi every one, i need adding tax id code to invoice and order process email notification.
what i must edit for it?
Enrico
what i must edit for it?
Enrico
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times