The VAT data displayed by the EU VAT Assistant is collected from the order data stored by WooCommerce. When the order is created, the EU VAT Assistant copies the billing and shipping country from the order, calling standard WooCommerce functions (WC_Order::get_billing_country()
, to be precise). That operation is performed when an order is created or updated, at checkout.
If the country information is not displayed by the widget, it means that either it wasn’t returned by those calls, or that it was deleted, somehow. The former possibility would also explain why the wrong VAT was charged. If the billing country was not there, WooCommerce would have charged the default VAT.
It’s difficult to speculate what the cause of the missing data could be, as WooCommerce doesn’t provide a log an order’s metadata contained when the checkout was completed. This isn’t an issue that we have encountered before, it looks it occurred in specific circumstances.
A good course of action would be to add some tracking code to monitor future orders. The EU VAT Assistant provides filter wc_aelia_eu_vat_assistant_store_vat_evidence
, which receives an array of VAT data being stored, as well as an order instance. This filter can be used for logging purposes, to check if the billing country stored against the order is blank.
Example
add_filter('wc_aelia_eu_vat_assistant_store_vat_evidence', function($vat_data, $order) {
// Log the billing country somewhere, or send an alert if it's blank . This can be done by
// using the WooCommerce logger
if($order->get_billing_country() === '') {
$logger = wc_get_logger();
$logger->debug('Order billing country is empty.', array(
'Order ID' => $order->get_id()
));
}
// Return the original VAT data
return $vat_data;
}, 10, 2);
-
This reply was modified 6 years, 6 months ago by
Diego.
-
This reply was modified 6 years, 6 months ago by
Diego.