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') ? – Luke Holder Dec 8 '16 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? – Terry Upton Dec 8 '16 at 7:56
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. – Terry Upton Jan 17 '17 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... – Jeremy Daalder Jan 17 '17 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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