taxjar / taxjar-woocommerce-plugin

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

Order prefixes #239

Closed devinsays closed 2 years ago

devinsays commented 2 years ago

Hi there. Sorry this is more of a support question than a feature request, but I think y'all could probably guide us best.

We are looking to set up multiple WooCommerce stores that all tie into the same TaxJar account. TaxJar support has recommended order prefixing so that we can have unique order numbers across all sites.

Is this something that is supported by the plugin? And if so, what is the best way to implement.

Here's the details from TaxJar support:

You are definitely able to connect multiple WooCommerce stores to the same TaxJar account and there is no issue with this provided that both stores would be reporting activity under the same business entity. In order to do this you would want to overwrite, as you suggested, the API key so that both stores are using the same TaxJar API token. This will allow each store to send order information into TaxJar for reporting and filing.

Currently when there are multiple instances of the same integration connected, there is no way to distinguish which orders are coming from a particular site. Everything will just show up as a WooCommerce transaction in TaxJar.

You will also need to ensure you have unique, non-repeating order numbers across both WooCommerce sites. Since the provider, WooCommerce, will be the same across both instances, if there are 2 order #1100 records, whichever is imported last would simply overwrite the initial record and you'd only see one order #1100 in TaxJar.

If you were able to implement some kind of order naming convention you could use that to not only prevent overlapping records, but also to distinguish between the two sites. For example website one could have a prefix for orders like this, web1-1100, and the second website could use a different prefix like web2-1100. Since the order IDs in this example are unique, TaxJar would see them as 2 separate transaction records but you could distinguish order #1100 for website one vs order #1100 for website two. I hope this helps as you work on the second WooCommerce store. Please let us know if there are any other questions we can assist with!

sethobey commented 2 years ago

Hi @devinsays 👋 thanks for reaching out!

Our plugin does indeed support this functionality through the use of taxjar-specific filters in TaxJar_Order_Record::class and TaxJar_Refund_Record::class.

To add your unique storefront transaction prefix, you will want to use the add_filter method to apply a custom callback function (usually added in your functions.php file) that will prepend the desired prefix to the default transaction identifier.

function add_custom_store_prefix( $id ) {
    return 'web1-' . $id;
}

add_filter('taxjar_get_order_transaction_id', 'add_custom_store_prefix');
add_filter('taxjar_get_refund_transaction_id', 'add_custom_store_prefix');

I'm going to close this issue now, but please feel free to reply to this comment for additional guidance if needed!

devinsays commented 2 years ago

Perfect! Thanks for getting us set in the right direction.