Post by Nicklez23 » Thu Oct 18, 2018 2:25 pm

Hello,

Last week my company managed to link our administration application called Snelstart with Opencart.
We want to send our customer data from Opencart to the administration program Snelstart.

The problem is we are able to send all our customers addresses, prices, etcetera.
But we are not able to send the VAT number to Snelstart, because the VAT number is a custom field.

Right now we transfer the customer data with the following code, and it's working:

$customer = array(
'customer_id' => $customer_id,
'first_name' => $orderdata['firstname'],
'last_name' => $orderdata['lastname'],
'company' => $orderdata['payment_company'],
'address' => $paymentaddress,
'city' => $orderdata['payment_city'],
'postcode' => $orderdata['payment_postcode'],
'state' => '',
'country' => $orderdata['isocountry'],
'email' => $orderdata['email'],
'phone' => $orderdata['telephone'],
);

But how do I find the code of a specific custom field in Opencart, so we can send the VAT numbers to Snelstart from Opencart?
I have tried the following lines:

'vatnumber' => $custom_field['BTW'],
'vatnumber' => $BTW,
'vatnumber' => $custom_field_id['BTW'],


My problem could be strange, but feel free to ask any questions.


Kind regards,

Nick de Laat

Newbie

Posts

Joined
Thu Oct 01, 2015 8:34 pm

Post by opencart.my » Sat Oct 20, 2018 10:40 pm

Hello Nick,

Could you try the following instead:

Code: Select all

'vatnumber' => implode(json_decode($orderdata['custom_field'], true)),
The raw data from $orderdata['custom_field'] will come in something like this:

Code: Select all

{"1":"10%"}
So we need 'json_decode' to turn it into an array, and 'implode' to turn the array into a string, which is "10%".

The value "1" is the custom field id where its title (e.g. 'VAT') won't be saved into the order.

Also, I noticed the custom field will only be saved into an order if the customer has Edited their Account and saved the custom field data themselves.

Hope it helps.

Developing Quality OpenCart Extensions since 2011. View my Extensions.


User avatar
New member

Posts

Joined
Mon Jan 22, 2018 6:03 pm

Who is online

Users browsing this forum: No registered users and 132 guests