SHOPIFY APP DISCOUNT FUNCTION

Topic summary

A developer is experiencing issues with Shopify’s discount function API when retrieving comparison pricing data through the compareAtAmountPerQuantity field.

The Problem:

  • An app that applies automatic discounts based on product metafields was working correctly until recently
  • The compareAtAmountPerQuantity field now consistently returns null, even when products have valid comparison prices set
  • The issue affects both the function API and direct GraphQL API calls

Technical Details:

  • The developer provided GraphQL query examples showing the field returning null in the response
  • The app relies on comparison pricing (compareAtAmountPerQuantity) from the CartLineCost object
  • Regular pricing (amountPerQuantity) continues to work as expected

Resolution:

  • Another user asked if the issue was resolved
  • The original poster confirmed they found a solution via a related Shopify Community thread about the same compareAtAmountPerQuantity bug in the discounts API
  • The discussion appears to be resolved through the referenced community post
Summarized with AI on November 4. AI used: claude-sonnet-4-5-20250929.

Hello, everyone,

We are developing an application that performs automatic discounts based on product metafiles.

This application makes use of comparison pricing.

As per the documentation, we are retrieving the compareAtAmountPerQuantity field

https://shopify.dev/docs/api/functions/reference/delivery-customization/graphql/common-objects/cartlinecost

Until a few weeks ago, the function worked perfectly by retrieving the right value of the comparison price.

But since a few days, that value is always null even though the product actually has the comparison price.

Can you explain why this is the case?

I have also tried calling Graphql api and even then the comparison price is always null.

query Input {

  cart {
        buyerIdentity {
              email
              customer{
                  hasTags(tags : ["star","vip","clienti","fidelity","vipmaffle"]){
                            hasTag
                            tag
                  }
              }
        }
        lines {
          id
          cost{
               prezzo: amountPerQuantity{
                                 amount
               }
               prezzoDiConfronto: compareAtAmountPerQuantity{
                                 amount
               }

          }
          merchandise {
                __typename
                ... on ProductVariant {
                  product {
                          star: metafield(namespace: "custom", key: "star") {
                                   jsonValue
                          }
                          vip: metafield(namespace: "custom", key: "vip") {
                                   jsonValue
                          }
                          clienti: metafield(namespace: "custom", key: "clienti") {
                                   jsonValue
                          }
                         fidelity: metafield(namespace: "custom", key: "fidelity") {
                                   jsonValue
                         }
                         vipmaffle: metafield(namespace: "custom", key: "vipmaffle") {
                                   jsonValue
                         }
                  }
                }
          }
        }
  }

  shop {
    localTime {
      date
    }
  }
}
{  "cart": {    "buyerIdentity": {      "email": "alessandroferraiuolo2@gmail.com",      "customer": {        "hasTags": [          {
            "hasTag": false,            "tag": "star"
          },
          {
            "hasTag": false,            "tag": "vip"
          },
          {
            "hasTag": true,            "tag": "clienti"
          },
          {
            "hasTag": false,            "tag": "fidelity"
          },
          {
            "hasTag": false,            "tag": "vipmaffle"
          }
        ]
      }
    },
    "lines": [      {
        "id": "gid://shopify/CartLine/0",        "cost": {          "prezzo": {            "amount": "110.0"
          },
          **"prezzoDiConfronto": null**
        },
        "merchandise": {          "__typename": "ProductVariant",          "product": {            "star": null,            "vip": null,            "clienti": {              "jsonValue": {                "valore": 90,                "dataStart": "2024-09-01T05:00:00Z",                "dataEnd": "2024-09-10T15:30:00Z"
              }
            },
            "fidelity": null,            "vipmaffle": null
          }
        }
      }
    ]
  },
  "shop": {    "localTime": {      "date": "2024-09-07"
    }
  }
}
 

 

Hey .Did you manage to fix ?

Yes with this topic:
https://community.shopify.com/post/2761466