Hi Brian!
That’s a great question. Way back when this functionality was built out in WP eCommerce – the decision was made to not use WordPress’s native acceptable mime-types – as you might not want any user to be able to upload all the file types that only authenticated users with the upload_files capability have.
That said, we do have a filter that allows you to add to the acceptable mime-types and extensions that can be uploaded. You rightly note that it currently is limited only to images (png/jpg/gif). To change it to allow PDFs, the following code should work for you – in your theme’s functions.php is fine, or if you have a custom functionality plugin already established, that’s a great spot for it as well.
add_filter( 'wpsc_customer_upload_accepted_file_types', function( $types ) {
$types['mime'][] = 'application/pdf';
$types['ext'][] = 'pdf';
return $types;
} );
Note: That example uses an anonymous function, which is compatible with PHP 5.3+. If you are on a host running < PHP 5.3, I’d recommend updating and/or naming the function.
Let me know how that works out for you!
Thread Starter
Brian
(@bwold)
Perfect! Thank you for this.
Thread Starter
Brian
(@bwold)
Quick follow up — the code change works. However, in the Admin > Store Sales > Sales Log Details, the path to the file is incomplete. It is missing the site URL and file upload location (from a variable, one assumes).
So I’m seeing http://adfile.pdf
…but would expect to see http://sitename.org/wp-content/uploads/wpsc/user_uploads/adfile.pdf
[url=http://postimg.org/image/dvbwpfp9z/][img]http://s23.postimg.org/dvbwpfp9z/wpec_saleslog.jpg[/img][/url]
Thread Starter
Brian
(@bwold)
Quick follow up: the file upload works now.
However, in Admin > Store Sales > Sales Log Details, the URL to the file is incomplete. (Missing the siteURL and upload path variables, one assumes…)
I’m seeing http://adfile.png
… but I’d expect to see http://sitename.org/wp-content/uploads/wpsc/user_uploads/adfile.png
http://s23.postimg.org/qzhh24hbv/wpec_saleslog.jpg
I see this line in purchaselogs.class.php, line 269:
$image = "<a href='" . esc_url ( WPSC_USER_UPLOADS_URL . $file['file_name'] ) . "' >";
Assuming the two variables are not getting set somehow… but that’s the limit of my tiny brain. Appreciate any additional help…