• Resolved jamesgallagher

    (@jamesgallagher)


    I’m using WC Fields Factory 1.2.4 with WooCommerce 2.5.1 and WordPress 4.4.1 to add a set of fields which includes a mandatory file upload for a particular product. When adding the product to the card an error message is displayed:
    Notice: Undefined index: wccpf_file_upload on <path-to>/product-form.php and it identifies line 128.

    I noted by doing a var_dump($_REQUEST) that the array didn’t include the ‘file_upload’ id which was being checked. As far as I can see from Google (and as the remaining code in the file suggests), PHP moved information about file uploads out of $_REQUEST into $_FILES. So, as a workaround, I moved the line which retrieves the field of interest from $_REQUEST to after the check for whether the field type is ‘file’. A diff between my modified product-form.php and your released one thus looks like:

    ***************
    *** 125,133 ****
                    foreach ( $all_fields as $fields ) {
                        foreach ( $fields as $field ) {
                            $res = true;
    -                       $val = $_REQUEST[ $field["name"] ];
                            if( $field["type"] != "file" ) {
                                if( $field["required"] == "yes" ) {
                                    $res = apply_filters( 'wccpf/validate/type='.$field["type"], $val );
                                }
                            } else {
    --- 125,133 ----
                    foreach ( $all_fields as $fields ) {
                        foreach ( $fields as $field ) {
                            $res = true;
                            if( $field["type"] != "file" ) {
                                if( $field["required"] == "yes" ) {
    +                           $val = $_REQUEST[ $field["name"] ];
                                    $res = apply_filters( 'wccpf/validate/type='.$field["type"], $val );
                                }
                            } else {
    ***************

    https://www.ads-software.com/plugins/wc-fields-factory/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Notice: Undefined index: wccpf_file_upload on product-form.php’ is closed to new replies.