Please consider leaving a donation if you appreciate this information. Lightning network now available
If you’re a merchant selling goods to customers in Colorado, SB 21-260 establishes a retail delivery fee that merchants are required to collect and remit to the state of Colorado. If you wish to continue to sell to customers in Colorado, you will need a solution to collect this fee. Until a proper solution exists, this code snippet will serve as a band-aid solution.
Not sure what to do with code snippets? See What Do I Do With These Code Snippets?
Please consider leaving a donation if you appreciate this information. Lightning network now available
Karie says
This is super helpful! Any idea how to not have tax added on top of this delivery fee?
Will says
The 3rd parameter is “taxable” https://woocommerce.github.io/code-reference/classes/WC-Cart.html#method_add_fee you can pass
false
to that.Chris S. says
This works great, thank you.
However, it is adding it to Virtual and Downloadable products. Any way to exclude those?
Will says
Off the top of my head, the only thing I can think to do would be loop through the cart items to get a shippable total to apply the fee to rather than using the cart total.
Will says
Wait…I take that back. Basically, if the cart doesn’t require shipping, this fee shouldn’t be added so one could use the
needs_shipping
method as a conditional.Will says
I’ve updated the snippet…give that a try.