I'm using this module to add an image upload field to the add to cart form and for the most part everything works as expected. However, I'm having a minor issue.

Each product display is tied to nearly 100 product variations, so when the page loads everything is fine and there is 1 file upload field. The upload field is set to a maximum of 2 uploads (building a print shop). However, whenever an option is changed the add to cart form the second upload field is added to the form even though nothing has been uploaded yet. Also, a weight select box is being added as well.

I've hidden the display of the weight fields via css because they are unnecessary and don't go with the aesthetics of the design, but I'd rather not have to do that as well as not have the 2nd upload field show up randomly.

P.S. - I would be ok with both upload fields being visible by default.

I appreciate any assistance in fixing this issue.

Comments

ocastle’s picture

I'm also getting this issue with an unlimited file field,

Each ajax request on the add to cart form triggers the addition of another option to the file field with the weight order.

ocastle’s picture

It looks like when commerce_cart_add_to_cart_form() is called, initially the $line_item doesn't have the said field in the object as its added later in the field attach...

field_attach_form('commerce_line_item', $form_state['line_item'], $form['line_item_fields'], $form_state);

But when this is called again in the ajax request, the $line_item object already has the field, so field_attach_form appends another field onto the same field.

Joe Huggans’s picture

Also having this problem... Was there a solution?

Joe Huggans’s picture

Really stuck on this one. I am making aprint shop and this is impossible without the ability to upload files

JCTWeb’s picture

Any progress on this problem? I'm having the same problem. Is this even related to this module? I'm using the regular product line-item type. I came to this module hoping to find a solution.

Joe Huggans’s picture

Hi JCT,

the only solution I found was to create a standard upload file field and use CSS to hide the upload button. So the file would upload when the use clicks add to cart. Unfortunately there isn't any widget that works without breaking the add to cart form (in my case anyway).

The upload button also seemed to break things, hence the hiding of it.

Joe Huggans’s picture

Is there a better solution for this yet? i.e a different upload widget?

nvahalik’s picture

Looks like this issue is a duplicate of the referenced issue.