delivery step actions
This commit is contained in:
@@ -12,6 +12,35 @@ class Wiaas_Document_Download {
|
||||
if ( isset($_GET['wiaasdoc']) ) {
|
||||
add_action( 'init', array( __CLASS__, 'admin_download' ) );
|
||||
}
|
||||
|
||||
if (isset($_GET['gf-wiaas-order-doc'])) {
|
||||
|
||||
add_action( 'init', array( __CLASS__, 'admin_gf_order_document_download' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle download for order documents by gravity flow steps
|
||||
*/
|
||||
public static function admin_gf_order_document_download() {
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
wp_die( __( 'No Access.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
// relative file path from upload dir for document
|
||||
$version = urldecode($_GET['gf-wiaas-order-doc']);
|
||||
|
||||
$file_path = wiaas_get_document_version_path($version);
|
||||
|
||||
if (!file_exists($file_path)) {
|
||||
wp_die( __( 'Document not found.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 404 ) );
|
||||
}
|
||||
|
||||
WC_Download_Handler::download_file_force(
|
||||
$file_path,
|
||||
pathinfo( $file_path, PATHINFO_FILENAME ) . '.' . pathinfo( $file_path, PATHINFO_EXTENSION )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user