Home Forums Plugin Support WP User Frontend Pro woo_files not updating / showing in back end

This topic is: resolved

This topic contains 8 replies, has 3 voices, and was last updated by  David 9 months, 1 week ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #15950
    acav802
    Post count: 19

    I’m using the woo_files meta for my users to be able to upload digital download products. I noticed that it has not been showing up in the back end recently.

    DId they maybe change this value in 2.1 WooCommerce? Anybody else notice this?
    My field in WPUF Custom fields does show in back end, but it should also be showing in “Downloadable Files:” under WooCommerce Product Data.

    Thank you.

    #16408
    David
    Post count: 7

    I’m having the same issue as well… the file uploads and shows under the WPUF Custom Fields but not showing in the Woo Commerce downloadable files field. Any ideas?

    #16412
    Key Master
    Tareq
    Post count: 2807

    Sorry I didn’t reply.

    Woo changed it’s meta key for downloadable urls. Now it’s _downloadable_files.

    #16448
    David
    Post count: 7

    Tareq, I still think what you have in the docs is incorrect though. Because after inspecting the DB for the array storage, since 2.1 I think the array storing the files is structured different from what you have in the docs? Any insight?

    #16457
    David
    Post count: 7

    Found the fix!
    Essentially the issue is WooCommerce 2.1+ updated the field storing Downloadable Files. My guess is so that more than one file can be supported per product.

    1. As Tareq mentioned, the new Meta Field Name is _downlodable_files

    2. The storage method is also slightly updated to use a multi-dimensional array. The following code will work, however you will need to update “File Name” to be a field or some valid variable storing the file name for the particular row. Or if you don’t care about it, just leave it null.

    function wpufe_woo_file_paths( $post_id ) {
        if (isset( $_POST['wpuf_files']['woo_files'])) {
    
            $files = $_POST['wpuf_files']['woo_files'];
            $fileName = 'Some File Name';
            $woo_files = array();
     
            foreach ($files as $file_id) {
                $file_url = wp_get_attachment_url( $file_id );
                $woo_files[md5( $file_url )] = array(
    				'name' => $fileName,
    				'file' => $file_url
    			);
            }
            update_post_meta( $post_id, '_downloadable_files', $woo_files );
        }
    }
    add_action( 'wpuf_add_post_after_insert', 'wpufe_woo_file_paths' );
    add_action( 'wpuf_edit_post_after_update', 'wpufe_woo_file_paths' );

    And if you’re curious, we’re using WPUF on our soon releasing http://slowroasted.co

    #16460
    Key Master
    Tareq
    Post count: 2807

    Ok, great!

    I see you are creating a marketplace, have you seen our version marketplace based on WooCommerce? :)

    #16634
    acav802
    Post count: 19

    Thanks I am going to try this!

    #16638
    acav802
    Post count: 19

    David thanks for your help on this

    I was a little confused about creating a field for the $fileName variable. Should it be a hidden field?

    If I don’t create a field, should i just use:

    $fileName = '';

    Thanks!

    #16639
    David
    Post count: 7

    acav, That’s right! The value isn’t required so you could set it to null or something else useful to you! Let me know if it works or if I can be of further help.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.