Before we dive in this week’s function, please note that it’s usually against any payment provider’s Terms of Service (like PayPal’s) to add fees to a transaction based on the customer’s chosen payment gateway, so please make sure to use “cart fees” in a legal way.
You got it — in this issue we’ll study the add_fee
WooCommerce function, which indeed gives us the power to add custom fees to orders at checkout based on any criteria you define.
As usual, we’ll study the WooCommerce core function code, see where and why it’s used, and finally we’ll cover a quick case study. Enjoy!