Costumer file upload on checkout

Hi, is possible to have a file upload field on checkout?
Comments
  • fc_adamfc_adam FoxyCart Team
    @leaodonorte,

    It is! While we don't support it natively, it is possible to add in a custom option for uploading files using a service like Uploadcare - you can see a quick tutorial on using that here: https://www.foxy.io/tutorials/uploadcare-add-file-upload-option-to-foxy-checkout
  • enmincenminc Member
    edited October 19
    Here is a working solution to make the Uploadcare Widget required on checkout.

    Note: Since the widget uses a hidden field to store the url of the uploaded file the data-required attribute will not work. Below is a javascript solution along with error flagging.

    Note#2: Your will have to play with the selector for the addClass and removeClass calls. Depending on how you have added the widget to the checkout and the possible custom html markup around the widget you may need to adjust to get the class in the proper container. #file-container will not work as copied below on its own.


    <script type="text/javascript">

    function checkForFile() {
    var haveFile = jQuery('input[name="file"]').val();
    if (haveFile !== '') {
    $('#file-container').removeClass('fc-alert-container--error');
    return true;
    } else {
    $('#file-container').addClass('fc-alert-container--error');
    alert("Documentation - Is Required");
    return false;
    }
    }
    var widget = uploadcare.Widget('[role=uploadcare-uploader]');

    widget.onUploadComplete(function(info) {
    //alert('upload complete');
    checkForFile();
    });

    FC.client.on("checkout-submit", checkForFile);
    </script>
  • brettbrett FoxyCart Team
    @enminc Awesome. Thanks for sharing!
Sign In or Register to comment.