1

Is there any automatic Error trapping built into Craft for discount codes for the following rules?

  • Orders over a set Total
  • Orders over a set Quantity

The codes work/apply, but if the rules don’t match I am not getting any errors/messages back. Any ideas? Do we have to write checks for every scenario?

There are likely more scenarios than the two I have listed above. It seems a little poor UX to appear to do nothing, no error, no discount applied if the contents of the cart don't qualify.

2
  • Can you get the error with cart.getError('couponCode') ? Commented Dec 8, 2016 at 0:47
  • No error is returned. I'm guess as there isn't an error as such. Just the cart contents don't qualify the discount. Once they do the discount is automatically applied. There are several instances of this. Is this something that could be expanded to better error trap? Commented Dec 8, 2016 at 7:56

1 Answer 1

1

So this is for coupons?

If a coupon can't be applied during an updateCart, you'll get back the rather unhelpful response in JSON of {"error":"Cart not completely updated."}

We intercept this, and because we know it's a coupon operation just replace the text of that to 'Could not apply coupon'.

But it does not give you a reason or anything, unfortunately.

2
  • can I ask how you intercept and output the error message? Even some form of feedback would be useful. Commented Jan 17, 2017 at 16:22
  • I just check for response.success and response.error - and take appropriate action in the JS from there. In our case we throw up a little red x and pop up message on the button. Meet me on slack if you need more specifics... Commented Jan 17, 2017 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.