Cart Transform lineExpand quantity limit

I need to expand a line item based on certain line item attributes to add a “customisation fee”. There are 2 types of fees I’d like to add - a per-quantity fee and a flat fee.

In my function, when I do something like:

{
  "operations": [
    {
      "lineExpand": {
        "cartLineId": "gid://shopify/CartLine/42db8d50-0d2f-4b28-ba9a-4ec51ba0cda1",
        "expandedCartItems": [
          {
            "merchandiseId": "gid://shopify/ProductVariant/56121401737481",
            "quantity": 1
          },
          {
            "merchandiseId": "gid://shopify/ProductVariant/56121401475337",
            "quantity": line.quantity
          }
        ]
      }
    }
  ]
}

I want the 2nd item to scale based on line.quantity(per-quantity fee), while the first one always remains 1 (flat fee). However, this seems to always be multiplied by the quantity of the line item itself, which I do not want.

How can I work around this? I’d like to achieve this via the Functions since this needs to work across different Shopify surfaces.

1 Like