0

I have a form - each variant is displayed thus:

<input type="number" data-id="12345" value="10"/>

I then use some jQuery to loop through all the inputs - grab the data-id, and value (quantity) and do an ajax post to add to cart etc... it all works as intended.

The problem comes when trying to handle file uploads. Specifically: I'm trying to sell caps in various colours. The customer may choose 3 red, 4 blue, 7 grey etc... and may also wish to upload their logo - to be printed on the cap.

I've tried to ajax post the logo as a line item property - but this doesn't work. Is there any way I can post the chosen variants (with quantity) and also uplaod a file at the same time?

Thanks, Rob

QTY and FileName are variables - and I've got stuff around it to take care of all the async. - Standard shopify way of doing things... but the file wont upload.

jQuery.post('/cart/add.js', {
  quantity: QTY,
  id: 794864229,
  properties: {
   'File': FileName'
  }
});
Rob
  • 1,576
  • 3
  • 22
  • 52
  • Just your bog standard, shopify ajax post.... adding now – Rob Jul 15 '15 at 14:47
  • you have to add `enctype` to ajax, maybe can work if you try [this](http://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax) – miglio Jul 15 '15 at 16:33

0 Answers0