Aborting with error message on Before Insert in eCommerce

Matt Mason asked on July 28, 2014 21:56

I'm trying to prevent members from using a PO box on the ship to address because fed-Ex doesn't deliver to PO, FPO or APO boxes.

I was thinking that I would just write another event for the OrderInfo on the before event:

public override void Init() { CMS.Ecommerce.OrderInfo.TYPEINFO.Events.Insert.Before += Insert_Before; }

But in the Insert_Before event I don't know how to send an error message, and not allow the order to go through and give them an opportunity to give a real address. Any ideas?

Recent Answers

Brenden Kehren answered on July 29, 2014 02:00

In your event, simply throw a new exception and set the message to whatever you want. You should be able to capture that exception on the front side. I believe you can cancel the event from processing as well.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.