I am trying to apply a coupon code to a users session so that when they add a product to the cart and go to check the coupon is automatically applied to the cart.
This thing is that the user comes from a 3rd party system to a specific hidden url and based on some url parameters we will apply different coupon codes. The problem is that at this point the user does not have any products in their cart.
I found this and it works but only if you already have products in the cart. If a user go to this url and then adds a product to the cart the coupon code is not applied. Any ideas how this can be accomplished?