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

Did you select a customer first? then add order?

DL:{ENTITY DATA:Customer:DiscountLevel} PR:[=-1*TN('{ITEM TAG:D{ENTITY DATA:Customer:DiscountLevel}}')]

Is your Entity Name Customer ?

2 Likes

Yes, the customer is selected, and I can’t show any entity data at all


Right! I changed the entity name recently
 forgot about that :slight_smile:

It’s working now, but still has a few glitches:

  • the user can change the discount by clicking the order tag buttons
    Is there any way to make these invisible or something?
  • when I change the customer, the discount stays
    I guess I can solve that with Ticket Entity Changed rule and Tag Order action
  • this does not discount orders that were already on the ticket before the customer was selected

@pipo your idea of storing the value I think might fit your needs better
 I would explore that. I still have interest in attempting a build but I realized I have other priorities I want to finish first namely my system breakup into Database Tool Files.

1 Like

Hm
 I really wish we could have an order looper

What happened with that idea @emre?

Don’t map the Order Tags (leave mapping blank), and they won’t show up


Haven’t figured out what to do with these yet - this is the challenge.

That would do the trick
 though there may be another solution.

1 Like

I’m trying out the other way (with discount applied to whole ticket), and I’m already running into a problem:

I’ve tried about everything I could think of to combine DL and TT into DLTT, but whatever I tried either gave me things like “}”, “}]” or just made sambapos crash


You’re missing the function TN().

[=TN('{TICKET TAG:D{ENTITY DATA:Customer:DiscountLevel}}')]

Should return the value for {TICKET TAG:D2} which you are showing as being 5.

I tried that as well, but it gives me this:

I used the exact same structure for TICKET TAG as for ITEM TAG, and it works for ITEM TAG, but not for TICKET TAG:


You correct, the Show Message Action is not evaluating properly, but it does apply the Ticket Tag regardless.

I am still using {ITEM TAG:X} to retrieve the discount value for the Product Tag:
[=-1*TN('{ITEM TAG:D{ENTITY DATA:Customer:DiscountLevel}}')]
, and the name of the Ticket Tag is being derived simply by:
D{ENTITY DATA:Customer:DiscountLevel}


At some point (probably at Payment), you will still need to Update Ticket Calculation in order to apply the the Ticket Tag Discount Values.

And of course, you still need to handle no customer, change customer, remove customer.

Plus, you need to think about Quantities of the product, especially if they are in different Order Lines, because adding the same Product more than once is not going to create multiple Ticket Tags, since the Tag has the same name


1 Like

What I want to do is add the amount to the ticket tag instead of just replacing it like now.
But I think the dynamic parameter construction still doesn’t work as it should.
This is what I have now:

[=TN(’{TICKET TAG:D{ENTITY DATA:ćźąäșș:Discount-level}}’)+(TN(’{ITEM TAG:D{ENTITY DATA:ćźąäșș:Discount-level}}’) * {QUANTITY})]

But it’s still just replacing the value of the Ticket tag instead of adding to it

It seems like the ticket tag is still not being used (=0) in the action parameter. Same thing as in the ShowMessage, it works for ITEM TAG but not for TICKET TAG


I just realize I’m doing it all wrong anyway!
I wanted to follow the outline I described before:

  • whenever an order is added to the ticket
    – you get the amounts for each discount-level, and add them to a program setting or ticket tag
    – if there’s already a customer entity linked to the ticket, you apply the appropriate discount to the ticket, based on the customer’s custom data
  • whenever an order is removed from the ticket
    – you get the amounts for each discount-level, and distract them from the program setting or ticket tag
    – if there’s already a customer entity linked to the ticket, you apply the appropriate discount to the ticket, based on the customer’s custom data
  • when the Ticket Entity Changed event is fired:
    – if there’s a customer entity, you apply the appropriate discount to the ticket, based on the customer’s custom data
    – if there’s no customer entity (the customer has been removed), you discard any ticket discount that was already there

So obviously I have to take the discount for every discount-level!
I think I’m too tired, I’m really messing up now!

This is what I should have done from the start:

and that works perfectly!

1 Like


 and I immediately see another problem, which I already had before, trying to implement something else (which is when I first started thinking I need an order looper):
I cannot catch the clicking of the plus and minus sign to increase/decrease the order quantity, so this method is again going to be useless


So it’s back to start again


Cumulative Tag working using Update Program Setting:


SettingName: D{ENTITY DATA:Customer:DiscountLevel}
SettingValue: [=TN('{ITEM TAG:D{ENTITY DATA:Customer:DiscountLevel}}')*{QUANTITY} +TN('{SETTING:D{ENTITY DATA:Customer:DiscountLevel}}')]

TagName: D{ENTITY DATA:Customer:DiscountLevel}
TagValue: [=TN('{SETTING:D{ENTITY DATA:Customer:DiscountLevel}}')]

Yes, but no matter how you do it, the problem is still:
You need to add to the number every time an order is added or increased, and distract when an order is removed/cancelled/voided/decreased. Most of these are not a problem, but the increase/decrease order quantity (plus and minus sign) cannot be caught with an event, so it’s impossible to implement this way


I had the same problem here:

and found nothing to solve that then


Pfffffffffffffffffffffffffffffff


Order looper where are you? :smile:

1 Like

Try handling Ticket Total Changed Event
 it is raised on click of +/-.

Your method looks cleaner, even if it is not dynamic, it is easier to understand.

1 Like

Any idea how to get the selected order’s price in the Ticket Total Changed rule?
I tried {PRICE}, but that just shows “{PRICE}”