DISCOUNT - Any Item - Ask Custom Percent

This method allows for a Discount Percent to be applied to Any Item, based on user input of a Percentage. It uses [?Request Input] notation to prompt the user to enter a percentage amount, then applies the Discount using a Tag Order Action.

Operational Flow:




Order Tag - Custom Discount Percent:

Automation Command - Discount Item Custom Percent:

Actions - Tag Order & UnTag Order:

Action - Execute Automation Command:


All Rules Require Default Mapping
All Rules Require Default Mapping
All Rules Require Default Mapping


Rule1 - Discount Update:

Actions:

ExecAutomationCmd (1)
CMDname: Discount Item Custom Percent NOT Zero
CMDvalue: [?Enter Discount Percentage (0=remove)]

ExecAutomationCmd (2)
CMDname: Discount Item Custom Percent Zero
CMDvalue: [?Enter Discount Percentage (0=remove)]

The notation [?prompt for input] requires the leading Question Mark!

The text in CMDname is important, because we need to match it exactly in the next 2 Rules, in their respective Constraint lists.

Also, the text in CMDvalue should be the same for both Actions - this will prevent being prompted twice.


Rule2 - Discount Item NOT zero: (apply Order Tag Discount)

TagNote: [=F([:CommandValue])]%
TagPrice: [=-1*(Order.Model.GetVisiblePrice()*[:CommandValue]/100)]

Rule3 - Discount Item zero: (remove Order Tag Discount)

3 Likes

@QMcKay

Hello. I also try this as well. It is the exhibiting same problem as the some the other one where I posted a video demo.

Thanks for your great help.

what is your problem exactly?

Thanks!!!

G

@gerlandog,

It is not prompting to enter discount amount. Were you able to get it to work?

yes…
with the [?something]
where something is the variable where to store the value entered with the keyboard.

in my case I used:

G.

@gerlandog,

I tried [?Discount Item Custom (Ask)] for Command Value and it is still not working. Which variable should I use? Thanks again.

why dont you use a one owrd variable?
in my case

DESCONTO

just to simplify and see what is going wrong in your setup…

G.

Tried one word, but it is still not working.

really strande… post your screens please!!

G

OR TRY THIS…Descuento_ITEM.zip (1015 Bytes)

1 Like

I will try your DB later tonight. Thank you.

Follow the Tutorial to the letter. It’s important. You need three Rules:

Update
Zero (the naming is important - it needs to be matched)
NOT Zero (the naming is important - it needs to be matched)

The notation [?prompt for input] requires the leading Question Mark!

The text in CMDname is important, because we need to match it exactly in the next 2 Rules, in their respective Constraint lists.

Also, the text in CMDvalue should be the same for both Actions - this will prevent being prompted twice.

I’ve updated the Rules above so you can use Copy/Paste.

Hi @QMcKay

I have followed this tutorial to the letter. I fixed the issue with ExecAutomationCmd. Also tried this tutorial on a different computer with SambaPOS being installed for the first time. I just can not seem to get this to work.

It is still the same issue that I posted yesterday. I select item to discount and I do not get prompted to enter discount.

At your convenience, can you please review screen shots below and let me know if you see something wrong.

Screen Shots

Thank you for your time.

All your screen look ok - I can’t see any issues.

Silly question: did you add a default mapping to each of the 3 Rules?

Something you can do to Test…
This is one of the most powerful troubleshooting tools in your arsenal: Add a Message Box Action as the first Action to your Rules:

For each of the Rules, add an Action to display a Message Box as the first Action in the list, to display a message stating which Rule is being executed (i.e “Update”, “Zero”, “Not Zero”).

At least that way, you should realize which Rule is failing.

@QMcKay

I did not add Default Mapping to all 3 Rules.

Added Show Message to all 3 Rules, but message box does not show when I press Discount button.

Rules with Show Message

Any possibility we can add these Discounts to SambaMarket?

Thanks again.

Is your Show Message Action the same as mine?

You need Default Mappings for Rules. They won’t work at all without them.

Your Message Action should have [:message], not [?message]. Then in the Rules you will need to remove the Message Action, and re-add it. You should then see a parameter box for message.

Hi @QMcKay

Adding Default Mapping to all Rules resolved my issue. Not sure how I missed that.

Thank you very much for your great tutorials and help.

Excellent!

I sometimes forget to mention that Rules need Default Mappings. Without them, the Rule is “inactive” and is completely ignored. :stuck_out_tongue:

@QMcKay,

Is there a way to add an additional constrain?

Ask Custom Percent–> Restrict numbers 0-100.
Ask Custom Amount–> Restrict amount to maximum price of the product.

These restrictions will prevent products having a negative price.

Best Regards,

You can add regular expressions to the Question. For example, the following expression requires alpha-numeric characters, and its length must be between 8 and 26 characters:

[?Enter New WiFi Password (8 characters minimum):([a-zA-Z0-9]{8,26})]

This portion is the constraint:

:([a-zA-Z0-9]{8,26})

I’m not great with writing regular expressions, so I would need to look up an example on how to restrict values based on your criteria. @emre is much better at it than I am.