number_integer (Could not coerce value * to String)

number_integer (Could not coerce value * to String)

Ridge1388
Shopify Partner
6 0 0

I am passing points in a draft order metafield to be used in a calculation after checkout.

 

I think* this was working before, but now I am finding the metafield object is returning an error:

 

The Metafield code I am passing in the draftOrder:

 

 

//The Metafields
metafields: [{
    description:    'Total Points Redeemed',
    key:            'redeemed',
    namespace:      'rewards',
    type:           'number_integer',
    value:          Math.ceil( redeemed * Config.points ) //Round up
}]

 

 

 

 

In this case, the value was 0 and the response I get from the server is:

 

 

Variable $input of type DraftOrderInput! was provided invalid value for metafields.0.value (Could not coerce value 0 to String)

 

 

 

 

If I wrap the value in String (i.e.)

value:          String( Math.ceil( redeemed * Config.points ) )

 

It appears to run successfully, then when I try to update the cart, I get:

 

 

0: {field: null, message: "Record is invalid"}

 

 

 

but removing the String() from the value just brings me back to the original error.

 

I switched my API version to the latest (2024-07) but still can't seem to get passed this.

 

Not sure if anyone has encountered this before!

 

Replies 0 (0)