Wow, 3 hours debugging to find out this was the problem for me too.
Thanks for the solution, what changed that init became to early?
One thing that made this particularly hard to debug was the fact I wasn’t getting the error message till I put a die()
in the WC()->cart->add_to_cart
function before the return. It was strange because it seemed to completely jump out of executing my code (even a die()
right after the WC()->cart->add_to_cart
call did nothing) and the page redirected without showing any errors.