Reputation: 5834
I'm aware that a product can be added via querystring in Magento.
Pattern:
/path/to/app/checkout/cart/add?product=[id]&qty=[qty]
And if I have a required custom options:
/path/to/magento/checkout/cart/add?product=$id&qty=$qty&options[$id]=$value
If custom option is for example "field" or "drop_down", it's simple;
My querstion is: How to add a product via querystring if one of custom option is a file type?
I would like to add a file, as custom option value, that is already uploaded on server with AJAX (before product is added to cart).
Can it be done? And how?
Thank you for any solution.
Upvotes: 0
Views: 2062
Reputation: 8836
Files must be uploaded with POST requests, not GET (query string). You cannot use the built in add to cart url in that way without modifying the controller, which is not a good idea. Instead maybe make your own add to cart controller and copy the code from the core action and adjust it to accept filenames in the query string.
However, I have a feeling you are just trying to add products to cart without loading a new page. What are you trying to accomplish?
Upvotes: 2
Reputation: 2583
Your custom option should be a filename (or some other unique reference to the file), not the file itself. Any code that needs to operate on the file can then use the filename to get to the actual file since it is already on your server.
Upvotes: 1