question

barrettjacksondev avatar image
barrettjacksondev asked zgreathouse Deactivated commented

Discounts Issue with Expansion

We are having the same issue as described in this question: https://community.clover.com/questions/2171/gettin...

This is a "real" issue. Is there a reason why the above question was closed and not answered by the Clover Development team? It seems counter productive (and risky as well) to expect additional calls to the Discount API's, as opposed to getting the appropriate information through the expand feature of an order.

Tim
OrdersDiscounts
10 |2000

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

zgreathouse avatar image
zgreathouse Deactivated answered zgreathouse Deactivated edited
There are two types of discounts to consider here: Line Item level Discounts and Order level Discounts. When requesting an Order with the REST API, you will get a list of the Order level Discounts applied (only if there was at least one Order level Discount applied). The Line Item discounts are not included.

Additionally, you can expand nested fields. For example, below I am expanding the Discount and LineItems Fields of the Order, but I am also expanding the Discounts Field of the expanded LineItems Field (lineItems.discounts). (See our docs for more information on expanding multiple fields, as well as nested fields)

Example Endpoint to get both Order Level discounts, as well as Line Items discounts in a single call:
https://apisandbox.dev.clover.com/v3/merchants/{mId}/orders/GMZQRZ6DE9NHP?expand=discounts,lineItems,lineItems.discounts

Example response:
{
    "href": "https://sandbox.dev.clover.com/v3/merchants/{mId}/orders/GMZQRZ6DE9NHP",
    "id": "GMZQRZ6DE9NHP",
    "currency": "USD",
    "employee": {
        "id": "4HKYYG4YD8E6E"
    },
    "total": 2428,
    "taxRemoved": false,
    "isVat": false,
    "state": "locked",
    "manualTransaction": false,
    "groupLineItems": true,
    "testMode": false,
    "payType": "FULL",
    "createdTime": 1536947864000,
    "clientCreatedTime": 1536947864000,
    "modifiedTime": 1536948293000,
    "discounts": {
        "elements": [
            {
                "id": "XZ1FDCAS2C3BT",
                "orderRef": {
                    "id": "GMZQRZ6DE9NHP"
                },
                "name": "10% Off",
                "percentage": 10
            }
        ]
    },
    "lineItems": {
        "elements": [
            {
                "id": "TGJ1B5QX98YG8",
                "orderRef": {
                    "id": "GMZQRZ6DE9NHP"
                },
                "item": {
                    "id": "VDR2QYCABGV9Y"
                },
                "name": "Moogle Plushie",
                "price": 1999,
                "itemCode": "1",
                "printed": false,
                "createdTime": 1536947864000,
                "orderClientCreatedTime": 1536947864000,
                "discounts": {
                    "elements": [
                        {
                            "id": "MBZD478MTW462",
                            "orderRef": {
                                "id": "GMZQRZ6DE9NHP"
                            },
                            "lineItemRef": {
                                "id": "TGJ1B5QX98YG8"
                            },
                            "name": "15% Off",
                            "percentage": 15
                        }
                    ]
                },
                "exchanged": false,
                "refunded": false,
                "isRevenue": true
            }
        ]
    },
    "device": {
        "id": "****************************"
    }
}
The above order has an order level discount of 10% and a Line Item which as an individual 15% discount.

I have submitted a ticket to make this clearer in our Docs. Thank you for pointing this out for us!
10 |2000

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

barrettjacksondev avatar image
barrettjacksondev answered zgreathouse Deactivated commented
Thank you for the information. We were under the impression since at the Order Level had the expand feature for discounts, it was available. I guess what we will do is compare the line totals to the order total and determine a Discounts call. Thanks. Let us know if you recommend something different.
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.

zgreathouse avatar image zgreathouse commented ·

*I believe I understand your question a bit better after further review. I have edited my answer to include an endpoint which I believe is more of what you may be looking for*

0 Likes 0 ·

Welcome to the
Clover Developer Community