Handle order documents
This commit is contained in:
@@ -26,6 +26,17 @@ function wiaas_documents_upload_dir() {
|
||||
* @return string
|
||||
*/
|
||||
function wiaas_get_document_version_path($version) {
|
||||
|
||||
// documents uploaded with gravity forms have relevant path to form entry upload folder
|
||||
if (strpos($version, 'gravity_forms') !== false) {
|
||||
|
||||
$wp_uploads = wp_upload_dir();
|
||||
$wp_uploads_dir = $wp_uploads['basedir'];
|
||||
|
||||
return $wp_uploads_dir . '/' . $version;
|
||||
|
||||
}
|
||||
|
||||
return wiaas_documents_upload_dir() . '/' . $version;
|
||||
}
|
||||
|
||||
@@ -182,7 +193,7 @@ function wiaas_get_standard_package_order_item_documents($order, $package_item_i
|
||||
|
||||
return array_map(function($doc) {
|
||||
// append document extension and name information
|
||||
$doc['extension'] = wiaas_get_doc_version_extension($doc['version']);
|
||||
$doc['extension'] = isset($doc['extension']) ? $doc['extension'] : wiaas_get_doc_version_extension($doc['version']);
|
||||
$doc['name'] = isset($doc['name']) ? $doc['name'] : wiaas_get_doc_version_filename($doc['version']);
|
||||
|
||||
return $doc;
|
||||
@@ -222,4 +233,20 @@ function wiaas_get_order_item_documents($order_item, $doc_type = null) {
|
||||
}
|
||||
|
||||
return $filtered_documents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve order other documents (not binded to any order item)
|
||||
*
|
||||
* @param int $order_id
|
||||
*
|
||||
* @return array|mixed
|
||||
*/
|
||||
function wiaas_get_order_other_documents($order_id) {
|
||||
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
$documents = $order->get_meta('_wiaas_other_documents', true);
|
||||
|
||||
return empty($documents) ? array() : $documents;
|
||||
}
|
||||
Reference in New Issue
Block a user