1

I am struggling to understand the correct way to get a custom option that is an uploaded file to attach correctly when adding a product to cart via graphql.

I have tried using

entered_options: [ {uid: option_uid, value: (see below) }]

where value has been:

  1. base_64 encoded image string
  2. JSON.stringify( {file_name: string_name_of_file,file_data: base64 image string} )

Each time I try to add the product to cart, the file is not uploaded. (The field is not required)

Any pointers on the best way to get the image to upload when the product is added to cart would be awesome!

Thank you!

1 Answer 1

0

Magento does not currently support it, sadly it is not that easy to find the fact that it does not support it.

https://developer.adobe.com/commerce/webapi/graphql/schema/products/interfaces/customizable-option/#:~:text=Adobe%20has%20not,currently%20not%20supported.

I've solved it by making a module that uploads the file if it receives a json encoded value the same as you would send in the REST API

https://github.com/rapidez/magento2-compadre/pull/1/files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.