I'm trying to dynamically set a product price, which I can do just fine. However when I try to apply a coupon that has a minimum spend, the coupon will not apply.
EDIT
The dynamic pricing updates and everything looks good, the apply_coupon just doesn't work when I have a minimum spend on the coupon. It's like it cannot see the newly calculated totals.
Anyone got any ideas?
$coupon_code = 'coupontest';
$cart = new WC_Cart();
$cart->add_to_cart(531, 1);
foreach( $cart->get_cart() as $cart_item ) {
$cart_item['data']->set_price( (float) 100 );
}
$cart->calculate_totals(); //this works! the prices are calculated correctly
//Minimum spend on the coupon is not met though?
$cart->apply_coupon($coupon_code); //this does not work!
Thanks!