• Resolved BenLinders

    (@benlinders)


    I got an order from someone from an EU country, ordering a downloadable product which is setup with digital goods VAT. The billing address is filled in correctly by woocommerce in the order.

    If I look at the VAT evidence in the order, it says:

    VAT evidence
    Location details
    Customer located in EU no
    Billing country
    Shipping country

    Billing country is blank in the VAT evidence.

    The IP address is filled in in the VAT evidence and “Country from IP address” shows the correct country, the same as in the billing address.

    How come that the Billing country in the VAT evidence is blank?
    Any way to trace where it went wrong?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Diego

    (@daigo75)

    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.
    Thread Starter BenLinders

    (@benlinders)

    Thanks Diego!

    I added the code you suggested so that there will be log when it happens again.

    The shipping country is empty, both in the Woocommerce data and in the VAT evidence. I’m assuming that’s ok as it is a digital product?

    Ben Linders

    Plugin Author Diego

    (@daigo75)

    Yes. The shipping country is not used for digital products, therefore it can be empty (example: https://prnt.sc/km1nkh).

    Thread Starter BenLinders

    (@benlinders)

    I got some logs using the above code where the billing country was missing.

    If I look in the log file it only mentions the text “DEBUG Order billing country is empty.”

    Where can I find more info?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Billing country missing in VAT evidence’ is closed to new replies.