I'm looking for a way to create a coupon programmatically during the checkout and delete it when the checkout is done. This needs to be done base on a bonus system where I check if the customer is allowed to have a bonus or not. The important thing is, that I don't want to make it as a normal coupon because customers shouldn't be able to append it by there own knowing the code.
I've only found solution to append a coupon or create it programmatically. I've found nothing about a temporary coupon during one checkout.
It's also important that this coupon can be combined with just one another coupon and not more.
This is my code:
if ( get_discount_points() < 100 ) {
//Customer has bonus status 1
} elseif ( get_discount_points() < 200 ) {
//Customer has bonus status 2
} else {
//Customer has bonus status x
by the discount percentage }
So is this even possible?