buy-button-js icon indicating copy to clipboard operation
buy-button-js copied to clipboard

Data fetch has stopped working in latest version

Open dannytrann opened this issue 1 year ago • 4 comments

There are some changes with the buy-button-js library on the latest version with the addition of MoneyV2 and 'presentmentPrices'when fetching data, it's not happy with the values returned.

I'm unsure what else to do.

This has broken my app and I can't find any steps on upgrading the buy-button-js when fetching data to return my products.

How do I rectify this when I've already updated the buy-button-js with npm to the latest version? "@shopify/buy-button-js": "^2.4.0",

(3) [{…}, {…}, {…}] 0 : extensions : {code: 'selectionMismatch', nodeName: "field 'price'", typeName: 'MoneyV2'} locations : [{…}] message : "Field must have selections (field 'price' returns MoneyV2 but has no selections. Did you mean 'price { ... }'?)" path : Array(2) 0 : "fragment VariantFragment" 1 : "price" length : 2 [[Prototype]] : Array(0) [[Prototype]] : Object 1 : extensions : {code: 'undefinedField', typeName: 'ProductVariant', fieldName: 'presentmentPrices'} locations : [{…}] message : "Field 'presentmentPrices' doesn't exist on type 'ProductVariant'" path : Array(2) 0 : "fragment VariantFragment" 1 : "presentmentPrices" length : 2 [[Prototype]] : Array(0) [[Prototype]] : Object 2 : extensions : {code: 'selectionMismatch', nodeName: "field 'compareAtPrice'", typeName: 'MoneyV2'} locations : [{…}] message : "Field must have selections (field 'compareAtPrice' returns MoneyV2 but has no selections. Did you mean 'compareAtPrice { ... }'?)" path : Array(2) 0 : "fragment VariantFragment" 1 : "compareAtPrice" length : 2 [[Prototype]] : Array(0) [[Prototype]] : Object length : 3 [[Prototype]] : Array(0)

dannytrann avatar Aug 23 '23 07:08 dannytrann

I am having the same issue with price and compareAtPrice. Funnily enough the app is broken, because the buy-button error handler does not handle more than one error message in my case.

bezin avatar Sep 15 '23 06:09 bezin

I am having the same issue with price and compareAtPrice. Funnily enough the app is broken, because the buy-button error handler does not handle more than one error message in my case.

I fixed it by changing the script tag to version 2.4.0 instead of 1.0.0..... lame fix but that did it for me

dannytrann avatar Sep 15 '23 06:09 dannytrann

Could you elaborate? You said in your opening comment, that you already upgraded to the latest version and the error still existed?

Nevermind: it was a caching issue in my case 🙈

bezin avatar Sep 15 '23 06:09 bezin

Sure, in my html file I have a

Previously, I assumed I should be using npm or something else like that but silly me didn't think tl change the actual js file from the script tag.

Try using this line

dannytrann avatar Sep 15 '23 06:09 dannytrann