• Resolved ludwikc

    (@ludwikc)


    Hello,

    Looking from the UX perspective, there’s no need to ask users for their personak details (billing address) when the product is free. (This applies e.g. to membership sites with free tiers.

    There are snippets and plugins to hide those fields in order to simplify user experience (basic check on WC()->cart->get_total being equal to 0)

    In this file:
    woocommerce-eu-vat-assistant/src/plugin-main.php around line 460, plugin applies filters on billing fields, which invalidates plugins and snippets like that.

    What can be done in order to work around this limitation of Aelia plugin? Or maybe you’d include this setting in your plugin itself?

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

    (@daigo75)

    We designed and tested the EU VAT Assistant with a standard WooCommerce installation, and that’s the scope of its compatibility. In a standard WooCommerce setup, the billing fields are always visible, even when the cart total is zero, therefore the EU VAT Assistant adds its fields following the same basic logic. This is by design, and it’s not a limitation (in fact, the behaviour can be customised easily, as described below).

    We’re not planning to add a feature to hide the fields when the cart total is zero, both because this can be done with a snippet (just like the ones you mentioned), and because the EU VAT Assistant is in maintenance mode, pending its retirement.

    If you wish, you can do that by hooking into the filter used by the EU VAT Assistant, and removing those fields when needed. You can do that in two ways:
    1. Write a filter for the hooks wc_aelia_eu_vat_assistant_show_checkout_field_vat_number and wc_aelia_eu_vat_assistant_show_checkout_field_self_certification, and return false when the cart total is zero.
    2. Write a filter for the hook woocommerce_checkout_fields, with a low priority (e.g. 9999). In the filter, check if the cart total is zero and, if it is, remove the fields by calling unset($fields['billing']['vat_number']) and $fields['billing']['customer_location_self_certified']).

    Either approach will allow you to customise the fields being displayed on the checkout page, just like the plugins and code snippets you mentioned do.

    Note
    For the benefit of other readers, I would like to add that the title of this thread is misleading. The EU VAT Assistant is 100% compatible with free orders. The fact that it shows its field even when an order has a total of zero is by design. The behaviour can be customised with a simple code snippet.

    • This reply was modified 3 years ago by Diego. Reason: Added link to the development plans FAQ for the EU VAT Assistant
    Plugin Author Diego

    (@daigo75)

    Example of how to remove the billing fields when the cart total is zero, or negative (which would make no sense, but it’s worth covering that angle).

    add_filter('woocommerce_checkout_fields', function($fields) {
      // The check is for "less or equal to zero" just in case. The cart total
      // should never be lower than zero, but one never knows
      if(WC()->cart->get_total('edit') <= 0) {
        // Remove the EU VAT Assistant fields if the cart total is zero
        unset($fields['billing']['vat_number']);
        unset($fields['billing']['customer_location_self_certified']);
      }
      return $fields;
    }, 9999);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘VAT assistant incompatibile with FREE orders’ is closed to new replies.