Do not apply AvaTax taxes if API credentials not validated

Created on 4 February 2025, about 1 month ago

I was seeing some odd messages when testing with Commerce SQL Sanitize today and discovered through some debugging, though perhaps unrelated to my issue, that Commerce AvaTax will attempt to apply taxes even if no API credentials have been configured yet. Since this module ships with a default tax type configuration, I believe this means your store is broken until you configure AvaTax upon installation of this module.

Any reason we don't add a check in Avatax::applies() to see if AvaTax has been fully configured?

  public function applies(OrderInterface $order) {
    $config = $this->configFactory->get('commerce_avatax.settings');

    // Do not apply if the API credentials aren't set.
    if (!$config->get('account_id') ||
      !$config->get('license_key') ||
      !$config->get('company_code')) {
      return FALSE;
    }

    return !$config->get('disable_tax_calculation');
  }
πŸ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rszrama

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024