WooCommerce JPlayer Product Sampler (https://www.woothemes.com/products/jplayer-product-sampler/) integrated in 3 steps:
1. onesocial-child/functions.php
/* WC Vendors Pro – Sample File Option */
function jplayer_update_field ( $post_id ) {
$title = get_post_meta( $post_id, ‘wcv_custom_product_sample_file_title’, true );
$file_path = get_post_meta( $post_id, ‘wcv_custom_product_sample_file_path’, true );
$jplayer_data[] = array( ‘title’ => $title, ‘path’ => $file_path );
update_post_meta( $post_id, ‘_jplayer_sample_file’, $jplayer_data );
}
add_action (‘wcv_save_product’,’jplayer_update_field’);
function wcv_file_uploader( ){
$value = get_user_meta( get_current_user_id(), ‘test’, true );
WCVendors_Pro_Form_Helper::file_uploader( array(
‘header_text’ => __(‘File uploader’, ‘wcvendors-pro’ ),
‘add_text’ => __(‘Add file’, ‘wcvendors-pro’ ),
‘remove_text’ => __(‘Remove file’, ‘wcvendors-pro’ ),
‘image_meta_key’ => ‘test’,
‘save_button’ => __(‘Add file’, ‘wcvendors-pro’ ),
‘window_title’ => __(‘Select an Image’, ‘wcvendors-pro’ ),
‘value’ => $value
)
);
}
2. onesocial-child/wc-vendors/dashboard/product-edit.php
<!– Add Preview File –>
<?php
WCVendors_Pro_Form_Helper::input( array(
‘type’ => ‘text’,
‘post_id’ => $object_id,
‘id’ => ‘wcv_custom_product_sample_file_title’,
‘label’ => __( ‘Sample file title for preview’, ‘wcvendors-pro’ ),
‘placeholder’ => __( ‘File title goes here. Leave blank if you don\’t have a sample file’, ‘wcvendors-pro’ ),
‘desc_tip’ => ‘true’,
‘description’ => __( ‘Leave blank if you don\’t have a sample file’, ‘wcvendors-pro’ ),
) );
WCVendors_Pro_Form_Helper::input( array(
‘type’ => ‘text’,
‘post_id’ => $object_id,
‘id’ => ‘wcv_custom_product_sample_file_path’,
‘label’ => __( ‘Sample file path for preview’, ‘wcvendors-pro’ ),
‘placeholder’ => __( ‘Click the Add file buttton below and paste here the URL. Leave blank if you don\’t have a sample file ‘, ‘wcvendors-pro’ ),
‘desc_tip’ => ‘true’,
‘description’ => __( ‘Click the Add file button upload your file and the select it and paste here the link of the file. You can find the link in the left details area’, ‘wcvendors-pro’ ),
) );
wcv_file_uploader();
?>
3. onesocial-child/wc-vendors-pro/public/class-wcvendors-pro-form-helper.php
echo ‘‘.$field[ ‘add_text’ ].’<br />’;