question

brokenoval avatar image
brokenoval asked brokenoval commented

How to add discount to atomicOrder?

I've tried adding discounts at both the order level and item level, and I've tried the following fields oulined in the API Documentation:


`ordercart.lineItems.priceWithModifiersAndItemAndOrderDiscounts`

`ordercart.lineItems.discounts.amount`

`ordercart.discounts.amount`

`ordercart.lineItems.discountAmount`

`ordercart.lineItems.orderLevelDiscountAmount`


The equivalent works for a `percentage` discount, but when I try to do an `amount` based discount I get the following error:

{
    "details": "[Invalid value for 'amount']",
    "message": "invalid_discount_attribute"
}


How can I add a value based discount to the item level and order level?


For reference, the full body I am posting:

{
  "orderCart": {
    "lineItems": [
      {
        "quantity": 1,
        "price": 250,
        "discountAmount":20,
        "orderLevelDiscountAmount":30,
        "item": {
          "id": "8SFWVR7Z3CNW0",
          "name": "Avo Go Go2",
          "price": 250,
          "taxRates": [],
          "taxRateValue": 0,
          "tags": ""
        },
        "modifications":[
            {
                "name":"True Nopal",
                "amount": 20,
                "modifier":{
                    "id":"N1GGT87M65RA8",
                    "modifierGroup":{
                        "id":"T167H9DA5SM8W"
                    }
                }
            },
            {
                "name":"True Nopal 2",
                "amount": 30,
                "modifier":{
                    "id":"N1GGT87M65RA8",
                    "modifierGroup":{
                        "id":"T167H9DA5SM8W"
                    }
                }
            }
        ],
        "discounts":[
            {
                "name":"TEST DISCOUNT2",
                "total": 10,
                "percentage": 0
            }
        ]
    },
    {
        "quantity": 1,
        "price": 250,
        "discountAmount":20,
        "orderLevelDiscountAmount":30,
        "item": {
          "id": "8SFWVR7Z3CNW0",
          "name": "Avo Go Go2",
          "price": 250,
          "taxRates": [],
          "taxRateValue": 0,
          "tags": ""
        },
        "modifications":[
            {
                "name":"True Nopal3",
                "amount": 20,
                "modifier":{
                    "id":"N1GGT87M65RA8",
                    "modifierGroup":{
                        "id":"T167H9DA5SM8W"
                    }
                }
            }
        ],
        "discounts":[
            {
                "name":"TEST DISCOUNT2",
                "total": 20,
                "percentage": 0
            }
        ]
    }
    ],
    "discounts":[
        {
        "name":"TEST DISCOUNT",
        "amount": 30,
        "percentage": 0
        }
    ],
    "groupLineItems": true
}
}


Thanks!

Orders
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

David Marginian avatar image
David Marginian Deactivated answered brokenoval commented

The discount amount needs to be negative "amount": -1000.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brokenoval avatar image brokenoval commented ·

Magic. Thanks - that's working as expected now.

0 Likes 0 ·

Welcome to the
Clover Developer Community