taxjar / taxjar-woocommerce-plugin

WooCommerce Sales Tax Plugin by TaxJar
http://www.taxjar.com/woocommerce-sales-tax-plugin/
GNU General Public License v2.0
28 stars 29 forks source link

Additional hooks/functions for tax calculation outside of WooCommerce #259

Open jordanmaurice opened 1 month ago

jordanmaurice commented 1 month ago

We are attempting to set up a Gravity Form that people can receive a quote for our products through, rather than navigating through the site. We want to include a tax amount calculated by TaxJar for the total, but we're not sure how to use the API outside of the plugin.

What I essentially want to do is have this kind of function:

function get_tax_amount($to_country, $to_zip, $to_state, $to_street, $amount, $shipping){
  $tax_amount = some_taxjar_function($to_country, $to_zip, $to_state, $to_street, $amount, $shipping); 
  return $tax_amount;
}

I'm aware there is the PHP library, but I'm not familiar with how to add that library to a WordPress website as we don't run composer or anything on our end.

Is there some kind of function that I can already access that I'm not aware of? I could not find any hooks/actions/functions documentation for the plugin.

ahumulescu commented 1 month ago

Hello,

Thank you for reaching out to us!

The following method is responsible for tax calculation: Tax_Client::get_taxes( $tax_request_body )

In theory, you should be able to manually use it in Gravity Forms as well. You would need to instantiate a $tax_request_body object using your data then call the get_taxes method with the created object.