# Automatic discount based on customer discount-level with set amounts per product

**URL:** <https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221>\
**Category:** V4 Question\
**Created:** [November 1, 2014, 6:45pm UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221 "2014-11-01T18:45:42Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [November 2, 2014, 9:03am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/41 "2014-11-02T09:03:03Z")

</div>

This might work…

```
[=Order.Model.GetVisiblePrice()]

```

This should work in certain cases too…

```
[=Order.Price]
```

---

<div class="post-metadata">

**Author:** ![pipo](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pipo/32/4085_2.png) [@pipo](https://forum.sambapos.com/u/pipo)\
**Post date:** [November 2, 2014, 9:04am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/42 "2014-11-02T09:04:09Z")

</div>

I’m not sure how to use Ticket Total Change to detect that the plus/minus buttons have been pressed.

I first thought something like this:  
if [:TicketTotal] Equals [:PreviousTotal] - {PRICE}  
then  
[=TN(’{TICKET TAG:D1}’)-TN(’{ITEM TAG:D1}’)]  
[=TN(’{TICKET TAG:D2}’)-TN(’{ITEM TAG:D2}’)]  
[=TN(’{TICKET TAG:D3}’)-TN(’{ITEM TAG:D3}’)]

if [:TicketTotal] Equals [:PreviousTotal] + {PRICE}  
then  
[=TN(’{TICKET TAG:D1}’)+TN(’{ITEM TAG:D1}’)]  
[=TN(’{TICKET TAG:D2}’)+TN(’{ITEM TAG:D2}’)]  
[=TN(’{TICKET TAG:D3}’)+TN(’{ITEM TAG:D3}’)]

… but that could also be another order added to the ticket…

---

<div class="post-metadata">

**Author:** ![pipo](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pipo/32/4085_2.png) [@pipo](https://forum.sambapos.com/u/pipo)\
**Post date:** [November 2, 2014, 9:08am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/43 "2014-11-02T09:08:41Z")

</div>

Hmm…  
[=Order.Model.GetVisiblePrice()] and [=Order.Price]  
both show 0

Maybe the order data is just not accessible in Ticket Total Changed?  
EDIT: they’re also not accessible when I add an order (and Ticket Total Changed is also triggered)

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [November 2, 2014, 9:11am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/44 "2014-11-02T09:11:34Z")

</div>

> [@pipo](#):
>
> Maybe the order data is just not accessible in `Ticket Total Changed`?

Yah, that appears to be the case… even `{ITEM NAME}` isn’t available, so we can’t tell which Product is being updated.

The `+/-` buttons have always been a strange one to capture with meaningful data… it was worth a shot.

---

<div class="post-metadata">

**Author:** ![pipo](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pipo/32/4085_2.png) [@pipo](https://forum.sambapos.com/u/pipo)\
**Post date:** [November 2, 2014, 9:14am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/45 "2014-11-02T09:14:58Z")

</div>

I think @emre was planning to throw them out anyway, or was that only the select/change entity buttons?

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [November 2, 2014, 9:15am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/46 "2014-11-02T09:15:17Z")

</div>

We need an Order Looper… I’m not happy with storing these as Ticket Tags in the first place - they should be Order Tags instead.

---

<div class="post-metadata">

**Author:** ![pipo](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pipo/32/4085_2.png) [@pipo](https://forum.sambapos.com/u/pipo)\
**Post date:** [November 2, 2014, 9:17am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/47 "2014-11-02T09:17:09Z")

</div>

That would definitely be the best… But it’s probably not an easy feat, since @emre is staying very quiet about it…

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [November 2, 2014, 9:19am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/48 "2014-11-02T09:19:55Z")

</div>

> [@pipo](#):
>
> was planning to throw them out

Yes, @emre has mentioned getting rid of some of the hard-coded buttons, such as `Change Price`, maybe `Ticket Note`… not certain what his plans are for `+/-.`

You can already hide the `Select Entity` buttons if you don’t map them to the `Ticket Type`…

![](https://forum.sambapos.com/uploads/default/original/3X/8/8/88d8fd2c5a31338982315b0f2f55961e8c9a24f0.png)

… and this has something to do with Entities too, but I haven’t played with it…

> [@\[New\] 4.1.69 Entity Screen Visibility](http://forum.sambapos.com/t/new-4-1-69-entity-screen-visibility/2998):
>
> We can change visibility of an entity screen for different entity selection cases. It can have three values: -All Entity Screen will be always visible -Ticket Entiity Screen will be visible when there is an active ticket. Useful for displaying screens for Entity Change operations. POS Entity screen will be visible when there is no active ticket. On this sample Customer Tickets screen will not displayed when you select Change Customer command.

---

<div class="post-metadata">

**Author:** ![pipo](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pipo/32/4085_2.png) [@pipo](https://forum.sambapos.com/u/pipo)\
**Post date:** [November 2, 2014, 9:22am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/49 "2014-11-02T09:22:56Z")

</div>

I see… Is there a way to add them again with an automation button then?

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [November 2, 2014, 9:40am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/50 "2014-11-02T09:40:29Z")

</div>

Yes, with `Change Ticket Entity` Action… a bit of a hidden feature:

 ![](https://forum.sambapos.com/uploads/default/original/3X/2/d/2dbf1219fd2ac89422ae6a0199c7b9082e2acb79.png) 

 ![](https://forum.sambapos.com/uploads/default/original/3X/0/a/0a5c7431ed50a3a2ac80ef61f9c2a9a9e90e38db.png)

---

<div class="post-metadata">

**Author:** ![pipo](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pipo/32/4085_2.png) [@pipo](https://forum.sambapos.com/u/pipo)\
**Post date:** [November 2, 2014, 9:44am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/51 "2014-11-02T09:44:14Z")

</div>

Nice!  
Does that mean you can open new tickets without having to close (and lock) the previous ticket?  
Or will this just change the table for the current ticket when you click on another table?

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [November 2, 2014, 9:47am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/52 "2014-11-02T09:47:11Z")

</div>

LOL, I had never tried this before… it turns out that it will let you select the table and add an order to it, and it even changes state (color). But when you close the ticket, then click Show Tables and select the same table, the order is missing, even thought the table is Orange.

EDIT: Hmm… the Order IS in fact assigned to the table, as evidenced by my Ticket Lister Widget, but when I bring up the Ticket by clicking on the Table, the Ticket is Empty… weird. However, if I load the Ticket by clicking on the Ticket Lister Widget, the Orders are there!

![](https://forum.sambapos.com/uploads/default/original/3X/9/5/95748c5f8429a14d13e15e5466799e41731f16a4.png)

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [November 2, 2014, 9:56am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/53 "2014-11-02T09:56:15Z")

</div>

Hey! What have we here??? Will need to play with tomorrow… 4am here now…

![](https://forum.sambapos.com/uploads/default/original/3X/0/e/0ec2072269171161f39f41b7963442fde62b3746.png)

---

<div class="post-metadata">

**Author:** ![pipo](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pipo/32/4085_2.png) [@pipo](https://forum.sambapos.com/u/pipo)\
**Post date:** [November 2, 2014, 10:00am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/54 "2014-11-02T10:00:44Z")

</div>

Wow… Interesting… That could be very useful…  
I doubt we’ll be able to use this to loop through the orders though?

---

<div class="post-metadata">

**Author:** ![pipo](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pipo/32/4085_2.png) [@pipo](https://forum.sambapos.com/u/pipo)\
**Post date:** [November 2, 2014, 10:02am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/55 "2014-11-02T10:02:57Z")

</div>

The tables screen is behaving differently with my setup. When I go to it it behaves exactly like the “move table” button…

---

<div class="post-metadata">

**Author:** ![pipo](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pipo/32/4085_2.png) [@pipo](https://forum.sambapos.com/u/pipo)\
**Post date:** [November 2, 2014, 10:15am UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/56 "2014-11-02T10:15:22Z")

</div>

I just tried out `Select orders` with `Select All` set to “True”. I assumed it would select all orders on the ticket, but it doesn’t seem to do anything.  
Tried with “Gift” in `Order State`, it also doesn’t do anything.  
Adding `Refresh Cache` doesn’t help either.

Maybe it’s just an empty shell, and @emre is still working on this?

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [November 2, 2014, 1:01pm UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/57 "2014-11-02T13:01:22Z")

</div>

Wow… It is very hard to handle all possible ticket changes and update discounts accordingly.

Ticket states can be useful for that. When ticket brought to a state (something like Locked state) you can execute `update order state` action. When there is no order selected on ticket that action will trigger for all orders one by one so you’ll be able to update orders.

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [November 2, 2014, 4:56pm UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/58 "2014-11-02T16:56:13Z")

</div>

I’ve created something working. It will give some idea about implementation details.

[SambaPOS49\_201411021844SQM.zip](https://forum.sambapos.com/uploads/default/original/3X/4/3/43644858958c44df40f10ac61a2610c7185f38f0.zip) (444.0 KB)

Use `Activate Ticket Discount` & `Deactivate Ticket Discount` actions to enable/disable (refresh) discounts.  
Use `Activate / Deactivate Order Discount` actions to enable disable discounts for specific orders.

Important Note: I’ve added `Hard Refresh Ticket` action to refresh order display but it won’t work for new created tickets and we shouldn’t refresh tickets as demonstrated there as it basically closes & reopens ticket. On next version it will automatically update order lines after entity selection so no refresh will be needed.

Note 2: Displaying custom fields issue is related with screen customization feature. I’ll try to improve that too. To display them right click on screen, enable customization and drag new fields from `Available Fields` section.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [November 2, 2014, 5:20pm UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/59 "2014-11-02T17:20:48Z")

</div>

> [@emre](#):
>
> Displaying custom fields issue is related with screen customization feature. I’ll try to improve that too.

Ok, I see… I managed to get the field to appear, however Screen Customization should not be affecting the visible fields in `Manage > Entities > Entity`, so I hope to see a specific improvement there.

 ![](https://forum.sambapos.com/uploads/default/original/3X/4/d/4d76dea42775169a63a854d065933a89430e03b5.png)

I forgot about the following as well, which works just fine either way, and I probably should be editing Entities this way to begin with… **Batch Entity Editor** :

 ![](https://forum.sambapos.com/uploads/default/original/3X/d/5/d512d54e1ab50597d5df4047fa8942c98d94b1d3.png)

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [November 2, 2014, 7:05pm UTC](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221/60 "2014-11-02T19:05:56Z")

</div>

> [@emre](#):
>
> I’ve created something working  
> SambaPOS49\_201411021844SQM.zip (444.0 KB)

Not really sure what to do with this?

![](https://forum.sambapos.com/uploads/default/original/3X/6/1/61992ef5b46164aa58c364f9f977c48f1eee9a35.png)

[Previous page](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221.md?page=2)

[Next page](https://forum.sambapos.com/t/automatic-discount-based-on-customer-discount-level-with-set-amounts-per-product/3221.md?page=4)
