id = 'checkout_files_upload';
$this->short_desc = __( 'Checkout Files Upload', 'woocommerce-jetpack' );
$this->desc = __( 'Let customers upload files on (or after) the checkout.', 'woocommerce-jetpack' );
$this->link_slug = 'woocommerce-checkout-files-upload';
parent::__construct();
if ( $this->is_enabled() ) {
add_action( 'add_meta_boxes', array( $this, 'add_file_admin_order_meta_box' ) );
add_action( 'init', array( $this, 'process_checkout_files_upload' ) );
if ( 'yes' === get_option( 'wcj_checkout_files_upload_remove_on_empty_cart', 'no' ) ) {
add_action( 'woocommerce_cart_item_removed', array( $this, 'remove_files_on_empty_cart' ), PHP_INT_MAX, 2 );
}
$total_number = apply_filters( 'booster_option', 1, get_option( 'wcj_checkout_files_upload_total_number', 1 ) );
for ( $i = 1; $i <= $total_number; $i++ ) {
if ( 'disable' != ( $the_hook = get_option( 'wcj_checkout_files_upload_hook_' . $i, 'woocommerce_before_checkout_form' ) ) ) {
add_action( $the_hook, array( $this, 'add_files_upload_form_to_checkout_frontend' ), get_option( 'wcj_checkout_files_upload_hook_priority_' . $i, 10 ) );
}
if ( 'yes' === get_option( 'wcj_checkout_files_upload_add_to_thankyou_' . $i, 'no' ) ) {
add_action( 'woocommerce_thankyou', array( $this, 'add_files_upload_form_to_thankyou_and_myaccount_page' ), PHP_INT_MAX, 1 );
}
if ( 'yes' === get_option( 'wcj_checkout_files_upload_add_to_myaccount_' . $i, 'no' ) ) {
add_action( 'woocommerce_view_order', array( $this, 'add_files_upload_form_to_thankyou_and_myaccount_page' ), PHP_INT_MAX, 1 );
}
}
add_action( 'woocommerce_checkout_order_processed', array( $this, 'add_files_to_order' ), PHP_INT_MAX, 2 );
add_action( 'woocommerce_after_checkout_validation', array( $this, 'validate_on_checkout' ) );
add_action( 'woocommerce_order_details_after_order_table', array( $this, 'add_files_to_order_display' ), PHP_INT_MAX );
add_action( 'woocommerce_email_after_order_table', array( $this, 'add_files_to_order_display' ), PHP_INT_MAX );
add_filter( 'woocommerce_email_attachments', array( $this, 'add_files_to_email_attachments' ), PHP_INT_MAX, 3 );
}
}
/**
* add_files_to_email_attachments.
*
* @version 2.7.0
* @since 2.5.5
*/
function add_files_to_email_attachments( $attachments, $status, $order ) {
if (
( 'new_order' === $status && 'yes' === get_option( 'wcj_checkout_files_upload_attach_to_admin_new_order', 'yes' ) ) ||
( 'customer_processing_order' === $status && 'yes' === get_option( 'wcj_checkout_files_upload_attach_to_customer_processing_order', 'yes' ) )
) {
$total_files = get_post_meta( wcj_get_order_id( $order ), '_' . 'wcj_checkout_files_total_files', true );
for ( $i = 1; $i <= $total_files; $i++ ) {
$attachments[] = wcj_get_wcj_uploads_dir( 'checkout_files_upload' ) . '/' . get_post_meta( wcj_get_order_id( $order ), '_' . 'wcj_checkout_files_upload_' . $i, true );
}
}
return $attachments;
}
/**
* add_files_to_order_display.
*
* @version 2.7.0
* @since 2.4.7
*/
function add_files_to_order_display( $order ) {
$order_id = wcj_get_order_id( $order );
$html = '';
$total_files = get_post_meta( $order_id, '_' . 'wcj_checkout_files_total_files', true );
for ( $i = 1; $i <= $total_files; $i++ ) {
$real_file_name = get_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_real_name_' . $i, true );
if ( '' != $real_file_name ) {
$html .= __( 'File', 'woocommerce-jetpack' ) . ': ' . $real_file_name . '
';
}
}
echo $html;
}
/**
* validate_on_checkout.
*
* @version 3.4.0
* @since 2.4.5
*/
function validate_on_checkout( $posted ) {
$total_number = apply_filters( 'booster_option', 1, get_option( 'wcj_checkout_files_upload_total_number', 1 ) );
for ( $i = 1; $i <= $total_number; $i++ ) {
if (
'yes' === get_option( 'wcj_checkout_files_upload_enabled_' . $i, 'yes' ) &&
$this->is_visible( $i ) &&
'disable' != get_option( 'wcj_checkout_files_upload_hook_' . $i, 'woocommerce_before_checkout_form' )
) {
if ( 'yes' === get_option( 'wcj_checkout_files_upload_required_' . $i, 'no' ) && null === wcj_session_get( 'wcj_checkout_files_upload_' . $i ) ) {
// Is required
wc_add_notice( get_option( 'wcj_checkout_files_upload_notice_required_' . $i, __( 'File is required!', 'woocommerce-jetpack' ) ), 'error' );
}
if ( null === wcj_session_get( 'wcj_checkout_files_upload_' . $i ) ) {
continue;
}
$file_name = wcj_session_get( 'wcj_checkout_files_upload_' . $i );
$file_name = $file_name['name'];
$file_type = '.' . pathinfo( $file_name, PATHINFO_EXTENSION );
if ( '' != ( $file_accept = get_option( 'wcj_checkout_files_upload_file_accept_' . $i, '' ) ) ) {
// Validate file type
$file_accept = explode( ',', $file_accept );
if ( is_array( $file_accept ) && ! empty( $file_accept ) ) {
if ( ! in_array( $file_type, $file_accept ) ) {
wc_add_notice( sprintf( get_option( 'wcj_checkout_files_upload_notice_wrong_file_type_' . $i,
__( 'Wrong file type: "%s"!', 'woocommerce-jetpack' ) ), $file_name ), 'error' );
}
}
}
if ( $this->is_extension_blocked( $file_type ) ) {
wc_add_notice( sprintf( get_option( 'wcj_checkout_files_upload_notice_wrong_file_type_' . $i,
__( 'Wrong file type: "%s"!', 'woocommerce-jetpack' ) ), $file_name ), 'error' );
}
}
}
}
/**
* add_file_admin_order_meta_box.
*
* @version 2.4.5
* @since 2.4.5
*/
function add_file_admin_order_meta_box() {
$screen = 'shop_order';
$context = 'side';
$priority = 'high';
add_meta_box(
'wc-jetpack-' . $this->id,
__( 'Booster', 'woocommerce-jetpack' ) . ': ' . __( 'Uploaded Files', 'woocommerce-jetpack' ),
array( $this, 'create_file_admin_order_meta_box' ),
$screen,
$context,
$priority
);
}
/**
* create_file_admin_order_meta_box.
*
* @version 3.4.0
* @since 2.4.5
*/
function create_file_admin_order_meta_box() {
$order_id = get_the_ID();
$html = '';
$total_files = get_post_meta( $order_id, '_' . 'wcj_checkout_files_total_files', true );
$files_exists = false;
for ( $i = 1; $i <= $total_files; $i++ ) {
$order_file_name = get_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_' . $i, true );
$real_file_name = get_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_real_name_' . $i, true );
if ( '' != $order_file_name ) {
$files_exists = true;
$html .= '
' . __( 'No files uploaded.', 'woocommerce-jetpack' ) . '
'; } else { $html .= '' . __( 'Delete all files', 'woocommerce-jetpack' ) . '
'; } echo $html; } /** * is_extension_blocked. * * @version 3.2.3 * @since 3.2.3 */ function is_extension_blocked( $ext ) { if ( 'no' === get_option( 'wcj_checkout_files_upload_block_files_enabled', 'yes' ) ) { return false; } $ext = strtolower( $ext ); if ( strlen( $ext ) > 0 && '.' === $ext[0] ) { $ext = substr( $ext, 1 ); } $blocked_file_exts = get_option( 'wcj_checkout_files_upload_block_files_exts', 'bat|exe|cmd|sh|php|php0|php1|php2|php3|php4|php5|php6|php7|php8|php9|ph|ph0|ph1|ph2|ph3|ph4|ph5|ph6|ph7|ph8|ph9|pl|cgi|386|dll|com|torrent|js|app|jar|pif|vb|vbscript|wsf|asp|cer|csr|jsp|drv|sys|ade|adp|bas|chm|cpl|crt|csh|fxp|hlp|hta|inf|ins|isp|jse|htaccess|htpasswd|ksh|lnk|mdb|mde|mdt|mdw|msc|msi|msp|mst|ops|pcd|prg|reg|scr|sct|shb|shs|url|vbe|vbs|wsc|wsf|wsh|html|htm' ); $blocked_file_exts = explode( '|', $blocked_file_exts ); return in_array( $ext, $blocked_file_exts ); } /** * add_files_to_order. * * @version 3.4.0 * @since 2.4.5 */ function add_files_to_order( $order_id, $posted ) { $upload_dir = wcj_get_wcj_uploads_dir( 'checkout_files_upload' ); if ( ! file_exists( $upload_dir ) ) { mkdir( $upload_dir, 0755, true ); } $total_number = apply_filters( 'booster_option', 1, get_option( 'wcj_checkout_files_upload_total_number', 1 ) ); for ( $i = 1; $i <= $total_number; $i++ ) { if ( null !== wcj_session_get( 'wcj_checkout_files_upload_' . $i ) ) { $session_data = wcj_session_get( 'wcj_checkout_files_upload_' . $i ); $file_name = $session_data['name']; $ext = pathinfo( $file_name, PATHINFO_EXTENSION ); $download_file_name = $order_id . '_' . $i . '.' . $ext; $file_path = $upload_dir . '/' . $download_file_name; $tmp_file_name = $session_data['tmp_name']; $file_data = file_get_contents( $tmp_file_name ); if ( ! $this->is_extension_blocked( $ext ) ) { // should already be validated earlier, but just in case... file_put_contents( $file_path, $file_data ); } unlink( $tmp_file_name ); wcj_session_set( 'wcj_checkout_files_upload_' . $i, null ); update_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_' . $i, $download_file_name ); update_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_real_name_' . $i, $file_name ); } } update_post_meta( $order_id, '_' . 'wcj_checkout_files_total_files', $total_number ); } /** * remove_files_on_empty_cart. * * @version 3.6.0 * @since 3.6.0 */ function remove_files_on_empty_cart( $cart_item_key, $cart ) { if ( $cart->is_empty() ) { wcj_session_maybe_start(); $any_files_removed = false; for ( $i = 1; $i <= apply_filters( 'booster_option', 1, get_option( 'wcj_checkout_files_upload_total_number', 1 ) ); $i++ ) { if ( null != ( $session_data = wcj_session_get( 'wcj_checkout_files_upload_' . $i ) ) ) { $any_files_removed = true; if ( isset( $session_data['tmp_name'] ) ) { unlink( $session_data['tmp_name'] ); } wcj_session_set( 'wcj_checkout_files_upload_' . $i, null ); } } if ( $any_files_removed && 'yes' === get_option( 'wcj_checkout_files_upload_remove_on_empty_cart_add_notice', 'no' ) ) { wc_add_notice( get_option( 'wcj_checkout_files_upload_notice_remove_on_empty_cart', __( 'Files were successfully removed.', 'woocommerce-jetpack' ) ) ); } } } /** * process_checkout_files_upload. * * @version 3.7.0 * @since 2.4.5 * @todo add option for admin to delete files one by one (i.e. not all at once) */ function process_checkout_files_upload() { wcj_session_maybe_start(); $total_number = apply_filters( 'booster_option', 1, get_option( 'wcj_checkout_files_upload_total_number', 1 ) ); // Remove file for ( $i = 1; $i <= $total_number; $i++ ) { if ( isset( $_POST[ 'wcj_remove_checkout_file_' . $i ] ) ) { if ( isset( $_POST[ 'wcj_checkout_files_upload_order_id_' . $i ] ) ) { $order_id = $_POST[ 'wcj_checkout_files_upload_order_id_' . $i ]; $order_file_name = get_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_' . $i, true ); if ( '' != $order_file_name ) { $file_path = wcj_get_wcj_uploads_dir( 'checkout_files_upload' ) . '/' . $order_file_name; unlink( $file_path ); $file_name = get_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_real_name_' . $i, true ); wc_add_notice( sprintf( get_option( 'wcj_checkout_files_upload_notice_success_remove_' . $i, __( 'File "%s" was successfully removed.', 'woocommerce-jetpack' ) ), $file_name ) ); delete_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_' . $i ); delete_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_real_name_' . $i ); do_action( 'wcj_checkout_files_upload', 'remove_file', $_POST[ 'wcj_checkout_files_upload_order_id_' . $i ] ); } } else { $session_data = wcj_session_get( 'wcj_checkout_files_upload_' . $i ); unlink( $session_data['tmp_name'] ); wc_add_notice( sprintf( get_option( 'wcj_checkout_files_upload_notice_success_remove_' . $i, __( 'File "%s" was successfully removed.', 'woocommerce-jetpack' ) ), $session_data['name'] ) ); wcj_session_set( 'wcj_checkout_files_upload_' . $i, null ); do_action( 'wcj_checkout_files_upload', 'remove_file', false ); } } } // Upload file for ( $i = 1; $i <= $total_number; $i++ ) { if ( isset( $_POST[ 'wcj_upload_checkout_file_' . $i ] ) ) { $file_name = 'wcj_checkout_files_upload_' . $i; if ( isset( $_FILES[ $file_name ] ) && '' != $_FILES[ $file_name ]['tmp_name'] ) { // Validate $is_valid = true; $real_file_name = $_FILES[ $file_name ]['name']; $file_type = '.' . pathinfo( $real_file_name, PATHINFO_EXTENSION ); if ( '' != ( $file_accept = get_option( 'wcj_checkout_files_upload_file_accept_' . $i, '' ) ) ) { // Validate file type $file_accept = explode( ',', $file_accept ); if ( is_array( $file_accept ) && ! empty( $file_accept ) ) { if ( ! in_array( $file_type, $file_accept ) ) { wc_add_notice( sprintf( get_option( 'wcj_checkout_files_upload_notice_wrong_file_type_' . $i, __( 'Wrong file type: "%s"!', 'woocommerce-jetpack' ) ), $real_file_name ), 'error' ); $is_valid = false; } } } if ( $this->is_extension_blocked( $file_type ) ) { wc_add_notice( sprintf( get_option( 'wcj_checkout_files_upload_notice_wrong_file_type_' . $i, __( 'Wrong file type: "%s"!', 'woocommerce-jetpack' ) ), $real_file_name ), 'error' ); $is_valid = false; } if ( $is_valid ) { // To session $tmp_dest_file = tempnam( sys_get_temp_dir(), 'wcj' ); move_uploaded_file( $_FILES[ $file_name ]['tmp_name'], $tmp_dest_file ); $session_data = $_FILES[ $file_name ]; $session_data['tmp_name'] = $tmp_dest_file; wcj_session_set( $file_name, $session_data ); wc_add_notice( sprintf( get_option( 'wcj_checkout_files_upload_notice_success_upload_' . $i, __( 'File "%s" was successfully uploaded.', 'woocommerce-jetpack' ) ), $_FILES[ $file_name ]['name'] ) ); // To order if ( isset( $_POST[ 'wcj_checkout_files_upload_order_id_' . $i ] ) ) { $this->add_files_to_order( $_POST[ 'wcj_checkout_files_upload_order_id_' . $i ], null ); } // Action do_action( 'wcj_checkout_files_upload', 'upload_file', ( isset( $_POST[ 'wcj_checkout_files_upload_order_id_' . $i ] ) ? $_POST[ 'wcj_checkout_files_upload_order_id_' . $i ] : false ), $_FILES[ $file_name ]['name'] ); } } else { wc_add_notice( get_option( 'wcj_checkout_files_upload_notice_upload_no_file_' . $i, __( 'Please select file to upload!', 'woocommerce-jetpack' ) ), 'notice' ); } } } // Admin file download if ( isset( $_GET['wcj_download_checkout_file_admin'] ) ) { $tmp_file_name = wcj_get_wcj_uploads_dir( 'checkout_files_upload' ) . '/' . $_GET['wcj_download_checkout_file_admin']; $file_name = get_post_meta( $_GET['post'], '_' . 'wcj_checkout_files_upload_real_name_' . $_GET['wcj_checkout_file_number'], true ); if ( wcj_is_user_role( 'administrator' ) || is_shop_manager() ) { header( "Expires: 0" ); header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); header( "Cache-Control: private", false ); header( 'Content-disposition: attachment; filename=' . $file_name ); header( "Content-Transfer-Encoding: binary" ); header( "Content-Length: ". filesize( $tmp_file_name ) ); readfile( $tmp_file_name ); exit(); } } // Admin all files delete if ( isset( $_GET['wcj_download_checkout_file_admin_delete_all'] ) && ( wcj_is_user_role( 'administrator' ) || is_shop_manager() ) ) { $order_id = $_GET['wcj_download_checkout_file_admin_delete_all']; $total_files = get_post_meta( $order_id, '_' . 'wcj_checkout_files_total_files', true ); for ( $i = 1; $i <= $total_files; $i++ ) { if ( '' != ( $order_file_name = get_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_' . $i, true ) ) ) { unlink( wcj_get_wcj_uploads_dir( 'checkout_files_upload' ) . '/' . $order_file_name ); } delete_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_' . $i ); delete_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_real_name_' . $i ); } delete_post_meta( $order_id, '_' . 'wcj_checkout_files_total_files' ); wp_safe_redirect( remove_query_arg( 'wcj_download_checkout_file_admin_delete_all' ) ); exit; } // User file download if ( isset( $_GET['wcj_download_checkout_file'] ) && isset( $_GET['_wpnonce'] ) && ( false !== wp_verify_nonce( $_GET['_wpnonce'], 'wcj_download_checkout_file' ) ) ) { $i = $_GET['wcj_download_checkout_file']; if ( ! empty( $_GET['wcj_download_checkout_file_order_id'] ) ) { $order_id = $_GET['wcj_download_checkout_file_order_id']; if ( ! ( $order = wc_get_order( $order_id ) ) ) { return; } if ( isset( $_GET['key'] ) ) { // Thank you page if ( ! $order->key_is_valid( $_GET['key'] ) ) { return; } } else { // My Account if ( ! wcj_is_user_logged_in() || $order->get_customer_id() != wcj_get_current_user_id() ) { return; } } $order_file_name = get_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_' . $i, true ); $tmp_file_name = wcj_get_wcj_uploads_dir( 'checkout_files_upload' ) . '/' . $order_file_name; $file_name = get_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_real_name_' . $i, true ); } else { $session_data = wcj_session_get( 'wcj_checkout_files_upload_' . $i ); $tmp_file_name = $session_data['tmp_name']; $file_name = $session_data['name']; } header( "Expires: 0" ); header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); header( "Cache-Control: private", false ); header( 'Content-disposition: attachment; filename=' . $file_name ); header( "Content-Transfer-Encoding: binary" ); header( "Content-Length: ". filesize( $tmp_file_name ) ); readfile( $tmp_file_name ); exit(); } } /** * is_visible. * * @version 3.6.0 * @since 2.4.7 */ function is_visible( $i, $order_id = 0 ) { if ( apply_filters( 'wcj_checkout_files_always_visible_on_empty_cart', false ) && 0 == $order_id && WC()->cart->is_empty() ) { // Added for "One Page Checkout" plugin compatibility. return true; } // Include by user role $user_roles = get_option( 'wcj_checkout_files_upload_show_user_roles_' . $i, '' ); if ( ! empty( $user_roles ) && ! in_array( wcj_get_current_user_first_role(), $user_roles ) ) { return false; } // Exclude by user role $user_roles = get_option( 'wcj_checkout_files_upload_hide_user_roles_' . $i, '' ); if ( ! empty( $user_roles ) && in_array( wcj_get_current_user_first_role(), $user_roles ) ) { return false; } // Include by product id $products_in = get_option( 'wcj_checkout_files_upload_show_products_in_' . $i ); if ( ! empty( $products_in ) ) { $do_skip_by_products = true; if ( 0 != $order_id ) { $the_order = wc_get_order( $order_id ); $the_items = $the_order->get_items(); } else { $the_items = WC()->cart->get_cart(); } foreach ( $the_items as $cart_item_key => $values ) { if ( in_array( $values['product_id'], $products_in ) ) { $do_skip_by_products = false; break; } } if ( $do_skip_by_products ) return false; } // Exclude by product id $products_in = get_option( 'wcj_checkout_files_upload_hide_products_in_' . $i ); if ( ! empty( $products_in ) ) { if ( 0 != $order_id ) { $the_order = wc_get_order( $order_id ); $the_items = $the_order->get_items(); } else { $the_items = WC()->cart->get_cart(); } foreach ( $the_items as $cart_item_key => $values ) { if ( in_array( $values['product_id'], $products_in ) ) { return false; } } } // Include by product category $categories_in = get_option( 'wcj_checkout_files_upload_show_cats_in_' . $i ); if ( ! empty( $categories_in ) ) { $do_skip_by_cats = true; if ( 0 != $order_id ) { $the_order = wc_get_order( $order_id ); $the_items = $the_order->get_items(); } else { $the_items = WC()->cart->get_cart(); } foreach ( $the_items as $cart_item_key => $values ) { $product_categories = get_the_terms( $values['product_id'], 'product_cat' ); if ( empty( $product_categories ) ) continue; foreach( $product_categories as $product_category ) { if ( in_array( $product_category->term_id, $categories_in ) ) { $do_skip_by_cats = false; break; } } if ( ! $do_skip_by_cats ) break; } if ( $do_skip_by_cats ) return false; } // Exclude by product category $categories_in = get_option( 'wcj_checkout_files_upload_hide_cats_in_' . $i ); if ( ! empty( $categories_in ) ) { if ( 0 != $order_id ) { $the_order = wc_get_order( $order_id ); $the_items = $the_order->get_items(); } else { $the_items = WC()->cart->get_cart(); } foreach ( $the_items as $cart_item_key => $values ) { $product_categories = get_the_terms( $values['product_id'], 'product_cat' ); if ( empty( $product_categories ) ) continue; foreach( $product_categories as $product_category ) { if ( in_array( $product_category->term_id, $categories_in ) ) { return false; } } } } // Include by product tag $tags_in = get_option( 'wcj_checkout_files_upload_show_tags_in_' . $i ); if ( ! empty( $tags_in ) ) { $do_skip_by_tags = true; if ( 0 != $order_id ) { $the_order = wc_get_order( $order_id ); $the_items = $the_order->get_items(); } else { $the_items = WC()->cart->get_cart(); } foreach ( $the_items as $cart_item_key => $values ) { $product_tags = get_the_terms( $values['product_id'], 'product_tag' ); if ( empty( $product_tags ) ) continue; foreach( $product_tags as $product_tag ) { if ( in_array( $product_tag->term_id, $tags_in ) ) { $do_skip_by_tags = false; break; } } if ( ! $do_skip_by_tags ) break; } if ( $do_skip_by_tags ) return false; } // Exclude by product tag $tags_in = get_option( 'wcj_checkout_files_upload_hide_tags_in_' . $i ); if ( ! empty( $tags_in ) ) { if ( 0 != $order_id ) { $the_order = wc_get_order( $order_id ); $the_items = $the_order->get_items(); } else { $the_items = WC()->cart->get_cart(); } foreach ( $the_items as $cart_item_key => $values ) { $product_tags = get_the_terms( $values['product_id'], 'product_tag' ); if ( empty( $product_tags ) ) continue; foreach( $product_tags as $product_tag ) { if ( in_array( $product_tag->term_id, $tags_in ) ) { return false; } } } } return true; } /** * maybe_get_image. * * @version 3.7.0 * @since 3.7.0 */ function maybe_get_image( $link, $i, $order_id = 0 ) { if ( 'yes' === get_option( 'wcj_checkout_files_upload_form_template_field_show_images', 'no' ) ) { if ( 0 != $order_id && isset( $_GET['key'] ) && ( $order = wc_get_order( $order_id ) ) && $order->key_is_valid( $_GET['key'] ) ) { $order_file_name = get_post_meta( $order_id, '_' . 'wcj_checkout_files_upload_' . $i, true ); $tmp_file_name = wcj_get_wcj_uploads_dir( 'checkout_files_upload' ) . '/' . $order_file_name; } else { $session_data = wcj_session_get( 'wcj_checkout_files_upload_' . $i ); $tmp_file_name = $session_data['tmp_name']; } if ( @is_array( getimagesize( $tmp_file_name ) ) ) { return '