Tags/topics: 
2
Answers
Vote up!
1
Vote down!

Can I create a Commerce File from code and add to cart?

My site allow users to upload file for processing and the system produce an output file that I want to add as commerce file product (unique for each user)from code. I can't find any example of products created from code that includes a commerce file?

I hope recrit can help here..anyone???

Thank you very much...

Asked by: bakulaw
on June 3, 2012

2 Answers

Vote up!
2
Vote down!

bakulaw,

You have a VERY specific use case here. Not only are you selling files, you are selling user generated files. Here's how I would do it without code:

1) I would follow this exercise for adding a field to your line item. http://joshmiller83.github.com/dc_docs/lineitems/LineItem-Customize.html

2) I would add a filefield instead of the simple text field to your custom line item

3) I believe you can tell Commerce File that it should handle this file field.

4) You should be able to add a line item "1 download" ? and then have them upload a file to their line item, and have Commerce File manage it.

Sounds complicated, but it might just work :-P

Josh

PS: This documentation page will be placed on drupalcommerce.org shortly.

Josh Miller
Answer by: Josh Miller
Posted: Jun 18, 2012
Vote up!
0
Vote down!

Has this method worked? I ask as I am also interested in doing something along these lines.

Answer by: Anonymous (not verified)
Posted: Oct 23, 2012