woo_files not updating / showing in back end

This topic contains 8 reply and 3 voices, and was last updated by David 10 years, 8 months ago
Viewing 8 Posts - 1 through 8 (of 8 total)
Author Posts
February 28, 2014 at 7:53 pm 15950
David 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.
March 11, 2014 at 10:27 am 16408
David David

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?

March 11, 2014 at 12:13 pm 16412
Tareq Hasan Tareq Hasan

Sorry I didn’t reply.

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

March 11, 2014 at 8:55 pm 16448
David David

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?

March 11, 2014 at 10:22 pm 16457
David David

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

March 11, 2014 at 11:07 pm 16460
Tareq Hasan Tareq Hasan

Ok, great!

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

March 15, 2014 at 2:04 am 16634
acav802 acav802

Thanks I am going to try this!

March 15, 2014 at 4:28 am 16638
acav802 acav802

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!

March 15, 2014 at 5:04 am 16639
David David

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 8 Posts - 1 through 8 (of 8 total)