If the data wasn’t collected, the reports won’t show it. The fix we applied is to ensure that the data will be collected for future, but the plugin won’t go through past order to update the missing VAT data. That will have to be done manually.
If you want to amend the orders, you can find the data in wp_postmeta table, with meta key _eu_vat_evidence. The data is a multi-dimensional array of data, the VAT number data is in the ‘exemption’ key.
Here’s an example of how you can update the VAT evidence with the VAT number data for order 123. You can use this script in a loop to update multiple orders:
// Get an order ID. Replace it with the appropriate ID
$order_id = 123;
// Load the order
$order = new \Aelia\WC\EU_VAT_Assistant\Order($order_id);
// Retrieve the VAT evidence
$vat_evidence = $order->get_vat_evidence();
// Store customer's VAT number, VAT country and VAT number validation status
$vat_evidence['exemption']['vat_number'] = $order->get_customer_vat_number();
$vat_evidence['exemption']['vat_country'] = get_post_meta($order_id, '_vat_country', true);
$vat_evidence['exemption']['vat_number_validated'] = get_post_meta($order_id, '_vat_number_validated', true);
// Update VAT evidence meta
update_post_meta($order_id, '_eu_vat_evidence', $vat_evidence);
Once the VAT evidence data has been updated, the VIES report will pick it up automatically.
Important
The above script is an example, provided as is, without guarantees. It makes permanent changes to orders meta, therefore we recommend that you test it on a staging copy of your site before running it on a live site.
-
This reply was modified 7 years, 9 months ago by
Diego.