in reply to Seeking configuration language for rules based system.

It would be nice to have a real configuration language, perhaps which uses opencyc which (when done) should be able to do the hard part. But not needed I think for your immediate problem. Incidentally I did not know about JESS, but did know about the CLIPS expert system package which it grew out of, and CLIPS is public domain. I have not used CLIPS but it does have a rule-based mode. There are example CLIPS programs here and while it would be very cool to use CLIPS in Perl, I think this sounds like overkill for your project.

I once had a problem where I thought of using rules and ended up encapsulating page layout subroutines so that I could write custom layout rules in a line or two of perl each. The motivation was that we had no database or perl, but we had a lot of content with similar layout for each hotel, plus not enough time to do it all by hand, and knowledge that changes might even so come in late (they did). This let me build a thousand page static website for fourteen hotels in the Mandarin Oriental group. Along with image compositing code I built with the gimp's perl server it resized all the photos and generated the entire site in just a few minutes. I call it "Magic Hands" because it looks like a really fast designer is sitting in front of Gimp and doing all the photo work.

In this case I had a lot of control since the "rules" were Perl code, and I was able to rebuild the entire site with new content a few times with extremely little pain, which is where it paid off. For example I could modify one entry in a data structure which said that for example we had two more photos for the Singapore franchise, and it would reinvent all the photo thumbnails, page navigation, and so on.

The neat thing is that once you find it is really easy to add something new, you do and you gain things you didn't think were possible. For example in my project you click on thumbnails to view images of hotel interiors, but we had given up on the idea of highlighting the clicked thumbnail. I was able to add this and even arrange the photos in a circle no matter how many photos there were on each page. Also, since I was able to refer to the parsed template files in the program, I was able to change where a certain link would go for every hotel just by changing a line of perl. I think you may find similarly that it becomes easy to add campaigns.

In your case a straightforward html form could make an easy-to-use interface which depending on your implementation might sacrifice power for ease of use. There was a recommendation above about looking at Outlook. Having helped someone recently clear his Eudora files of spam, I'd take a look at Eudora's mail filtering interface. Their downloadable manual shows how they let you actually do a lot of really great things, even regexes. You can also see an online tutorial and download Eudora itself. Their use of different ways to get to the same screen was confusing for me, but look at their documentation.. you will need to write a manual.

As an aside, one company I knew some years ago, Intertrust, actually was working on e-commerce rules (and I think Softbank is a partner) but it looks like they've refocused on digital rights management. I just mention them because I think they might have some patents regarding specification of chains of resellers but I think that is not something you need to worry about.

Anyway, look at Eudora's filters screen and see how it might apply to your interface. I'd recommend first rewriting your wishlist in pseudocode as if-then statements. This will help you see datasets which you will want to let your users maintain through separate form interfaces. For example a list of preferred customer classes might be one. Certainly the list of normal product prices is another set of data that should be handled with a separate interface. Then this rule-based form is for is for special cases and business logic only.

You'll need to make up a list of supported functions and handle internally logic (not done in Eudora) to make sure for example that even if you accumulate discounts you don't go beyond a certain percentage. (I recently saw a shopping cart that let you earn money.) This analysis will be needed even if you used someone else's system.

Another kind of interface which I find somewhat appealing would be to require the user to type rules in Perl code into an HTML text input field, and eval them in order. This would have the advantage of allowing you or another Perl person to do complicated things while they can do simple things without much help, possibly just changing a couple of numbers. You could put your error-checking logic into similar statements as well and even modify them from the web. One things you might consider is letting them type english words like "greater than" instead of the mathematical operators. You might even find some use in using a readline/prompt based shell that would eval commands you type in against test data to try out new rules.

Looking at it this way, your business logic starts to look like this..

DiscountAll(0.5) if CustomerClass = Student AdjustPrice(Gizmo, 30.00) if Quantity(Gizmo) > 9 DiscountAll(0.2) if OrdersToDate > 2 OfferFreeProduct(Gizmo) if Quantity(Widget) > 2 AdjustPrice(WidgetPlanB, 250.00) if Quantity(WidgetPlanB) > 2
Obviously you could make everything much more complex. This example is going to need only three data queries and three functions to change the order form.

Also it might be a good idea to let them type "if" first and let them type "then" instead of a curly-bracketed block. Likewise just an equals sign instead of "eq" perhaps. Maybe you could add the keyword "matches" which would let them type an alphanumeric string that could be used to match product or customer class names. You could even teach your customer a little SQL though maybe that's where angels fear to tread.. :) This could be useful for lots of things, please share your successes.