Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simphony C# Add Discount to individual Menu Item and not whole check

Status
Not open for further replies.

Simphunny

Programmer
Jun 20, 2024
2
GB
Hi,

I am able to add a discount to an individual check menu item by using the Simphony REST api

"Post a new round to a check"
POST {basePath}/checks/{checkRef}/round

JSON:
    "menuItems": [
        {
            "menuItemId": 123,
            "definitionSequence": 1,
            "name": "Item Name",
            "quantity": 1,
            "unitPrice": 1.00,
            "priceSequence": 1,
            "total": 1.00,
            "seat": 1,
            "surcharge": 0.0000,
            "condiments": [] ,
            "itemDiscounts": [
                {
                "discountId": 123,
                "name": "string",
                "seat": 0,
                "total": 2,
                "isAutomatic": true,
                "extensions": [
                    {
                    "displayName": "string",
                    "appName": "string",
                    "dataName": "string",
                    "dataType": "string",
                    "data": "string",
                    "options": [
                        "printOnDisplay"
                    ]
                    }
                ]
                }
            ]
            
        }
    ]


How can I acheive the same using the C# SDK?

I have tried the following code:

Code:
OpsContext.ProcessCommand(new OpsCommand(OpsCommandType.Discount) { Number = 123 });

But that applies the discount to the check and not the individual item on the check.

I have searched on the forum that someone used

Code:
OpsContext.ProcessCommand(new OpsCommand(OpsCommandType.DetailSelected) { Number = 1 });

to first select the menu item but that gave me an error saying "not found / not selected.

I am calling this code inside the Application_OpsMiEvent handler

Thanks in advance.
 
This code worked. You have to check "3 - This is an Item Discount" checkbox in the "General" tab of the Config UI for the discounts to be applied to each menu item instead of the whole check

Code:
private void ApplyItemDiscountToMenuItem(int menuItemDetailLink)
{
    const int DiscountId = 123;
    OpsContext.ProcessCommand(new OpsCommand(OpsCommandType.Macro)
    {
        Data = new List<OpsCommand>
        {
            new OpsCommand(OpsCommandType.DetailSelected) { Number = menuItemDetailLink },
            new OpsCommand(OpsCommandType.Discount) { Number = DiscountId }
        }
    });
}

private EventProcessingInstruction Application_OpsMiEvent(object sender, OpsMenuItemEventArgs args)
{
    var menuItemAddedDetailLink = args.DetailLink;
    ApplyItemDiscountToMenuItem(menuItemAddedDetailLink);
    return EventProcessingInstruction.Continue;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top