Cart Transform Not Updating Price in Draft Orders When Quantity Changes

Been running into this issue with a merchant of mine who uses the cart transform function to dynamically change the price of a line item (e.g. package protection) based on the cart total.

It’s been working well for a while, but up until a few weeks ago they noticed the function doesn’t actually update when the quantity of an item changes (custom item if it makes a difference). This seems to happen only form draft orders.

I haven’t changed anything on my end with regards to the cart transform function for the past few months, so I’m wondering if there was an update along the way between draft orders and the cart transform function, or maybe this is a caching issue because it seems to work okay if the item in question is removed and added again, but is there anything I can do to fix this or make it such that it properly updates on quantity change?

// api_version = "2024-04"

// Input
query RunInput {
  cart {
    lines {
      id
      quantity
      cost {
        totalAmount {
          amount
          currencyCode
        }
      }

      merchandise {
        ... on ProductVariant {
          id
        }
      }
    }
  }

  presentmentCurrencyRate

  localization {
    market {
      id
      handle
    }
  }

  cartTransform {
    metafield(namespace: "...", key: "...") {
      value
    }
  }
}


// Output
const cartTotalAmount = cart?.lines?.reduce?.((total, line) => {
          // I think cost.totalAmount refers to the whole line, not just a per unit cost
          return total + (Number(line?.cost?.totalAmount?.amount) || 0);
        }, 0);
        const newPrice = cartTotalAmount * (Number(priceChangeValue) / 100);

update: {
          cartLineId: lineId,
          price: {
            adjustment: {
              fixedPricePerUnit: {
                amount: newPrice,
              },
            },
          },
        },

Hey Kyle - Just wanted to let you know we’re digging into this here. Will give you an update asap.

Update here - our team have identified this is a bug and are working on a fix.