UWooCommerce – add cart discount programmatically?

I haven’t applied any discounts like that before, but have done it with ‘fees’ a lot.

Adding a fee is quite easy:

function custom_wc_add_fee() {
    WC()->cart->add_fee( 'Fee', -10 );
}
add_action( 'woocommerce_cart_calculate_fees','custom_wc_add_fee' );

(or if you want a plugin solution, I created this plugin: https://aceplugins.com/plugin/woocommerce-advanced-fees/)