Post by raptorheli » Sun Jan 20, 2019 2:39 am

Hi,
In the registration prosess in OC2.x there is a selection you select your organisasjon private or Company
I have created a custom field in registration when customers select business and the vat field appears
Q: is it possible to validate the vat number entered and compare to the vat registration database in norway WEB: https://www.brreg.no/
and validate if the entered number is valid or not....

catalog/controller/account/register.php
public function customfield() {
$json = array();

$this->load->model('account/custom_field');

// Customer Group
if (isset($this->request->get['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->get['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $this->request->get['customer_group_id'];
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}

$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);

foreach ($custom_fields as $custom_field) {
$json[] = array(
'custom_field_id' => $custom_field['custom_field_id'],
'required' => $custom_field['required']
);
}


Anyone on this one?

New member

Posts

Joined
Tue Mar 05, 2013 1:35 pm

Post by straightlight » Sat Jan 26, 2019 11:40 pm

This portion of your code:

Code: Select all

foreach ($custom_fields as $custom_field) {
$json[] = array(
'custom_field_id' => $custom_field['custom_field_id'],
'required' => $custom_field['required']
);
}
would need to be edited with an IF statement, below the foreach line, which you'd need to include your API / Webservices provider's defined object while validating the VAT number with the $custom_field array variable.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 259 guests