Use of CommandValue to select discount multiplier

I have a button that implements a selective 10% discount when pressed and I would like it to remove the discount when pressed again (for when the cashier makes a mistake and presses it by accident). I thought I could do this by toggling CommandValue between 0 or 10 and then using that value in my calculation as follows

The calculation works fine if I simply enter 10 or 0 into the Update Ticket Discount Rate action. What am I doing wrong here

I think it’s best to use ask question action in this case.

Here’s a database tools export file (1.1 KB)


One way to do this is to use a Calculation Type and a Calculation Selector.

1 Like

Thanks for the replies, but I am trying to avoid either asking a question or inputting a discount amount.

I have implemented a selective discount as per @emre guidelines

This works perfectly, except I have to enter 10 via the keypad to implement the 10% discount and simply press the button again to remove it (effectively entering a zero or null value I think). As we only ever have a 10% discount I initially modified the action to always enter 10, but this had the effect of not allowing the discount to be removed if the cashier made a mistake. I then figured I could use a [:CommandValue] expression with the CommandValue being toggled between 10 and 0 (as per screenshots above) but this has not worked as I expected.

I would prefer not to give the cashier the facility to choose a discount so would like to get this CommandValue idea working if possible.

Sorry I do not understand the issue
I did just like you and when I press the 10 have 10% discount

And when I press the 0 discount is canceled

It’s not what you want to happen?

That should be implemented as a Calculation Type.

This is our default %Discount Button. I’ve changed it as …

  • Configured a fixed rate.
  • Enabled Toggle Calculation setting.

After this change the %Discount button will always add %10 discount and will toggle as you click on it.

If you need to have this button on POS screen you can use Update Ticket Calculation action with an automation command. In this case you won’t need to configure a fixed rate on calculation template as you can set it through action. If you don’t want to see a discount button on Payment screen you can clear related Calculation Selector configuration.

1 Like

Thanks @emre for the reply. Unfortunately, implementing this as a %Discount button based on the rate from ticket amount will not work as this is selective discount with only pre-tagged items discounted. It works fine as a selective discount as originally described by yourself Selective Discount (1.4 KB) but we need to enter the discount required via the number pad which is picked up by a {:TENDEREDAMOUNT} expression and then used to calculate the discount.

Because we only ever use a 10% discount I originally changed the {:TENDEREDAMOUNT} expression to a simple 10 and everything worked nicely except that the discount cannot be reversed (if the cashier presses the button by mistake). I then though maybe I could use a CommandValue expression which toggled between 10 and 0 on the Automation Command but could not get this to do anything. My expectation of this operation is that the first time the button is pressed, it will set CommandValue=10 and this will be picked up by the [:CommandValue] expression in the *Update Ticket Discount Rate* action and used in the calculation. The second time the button is pressed it would pick up a zero and so on.

[EDIT] To try and understand this better, I set up a Test button with values set to Option 1 and Option 2 and mapped to Ticket & Payment.

This was linked to a show a message box action with message “Hello [:CommandValue]” when the button is pressed.

In the ticket screen the button shows as Option 1 or Option 2 and displays the selected CommandValue in the message as follows

In the payment screen the button shows as Test and the message when operated does not have the command value

This explains why the option of setting the discount with CommandValue is not working but it seems odd that the operation is different depending on the screen. Is this correct?

Thanks for the reply @pizzaeilat4. I do not get a 0 or 10 selector. Could you provide a bit more information on what you did to get this.

Unmark togglel values on automatIon command setting To get a 0 or 10 selector
I think It will solve your problem

set automatIon command

set action to update dicount

set rule to Execute update ticket discount

OK I remembered it. Do you have a ticket state related with discount?

You’ll have two different automation command buttons. One of them will add discount and the other one will remove discount.

You can show / hide these buttons as you add add / remove discount by maintaining a ticket state. For example you can have a Discount ticket state.

  • If Discount State is empty you can display Add Discount button.
  • When Discount state becomes Active you can display Remove Discount button.

So after applying / removing discount you’ll need to toggle ticket’s discount state and automation buttons will hide appear accordingly. These controlled by Visible State of automation command buttons. You can change ticket’s discount state by using Update Ticket State action.

If you’ll use these buttons on Payment screen you’ll also need to Refresh payment screen by executing Display Payment Screen action.

Discount (916 Bytes)

This Import file adds a sample Add Discount button to the payment screen. No discount functionality. Just demonstrates button toggle. All added rules prefixed with TGL_.

Thanks @emre. That is working perfectly now and I have learned a new trick as well :slight_smile:

As a matter of interest and to help in the future, is the somewhat odd behavior of the CommandValue expression described above correct, i.e. that it only works in the Ticket screen and not in the Payment screen?