Handle order documents
This commit is contained in:
@@ -96,7 +96,7 @@ class Wiaas_Order_Fields {
|
||||
continue;
|
||||
}
|
||||
|
||||
$bundle_item->update_meta_data('wiaas_installation_date', $new_value);
|
||||
$bundle_item->update_meta_data('_wiaas_installation_date', $new_value);
|
||||
$bundle_item->save_meta_data();
|
||||
|
||||
break;
|
||||
@@ -121,7 +121,7 @@ class Wiaas_Order_Fields {
|
||||
continue;
|
||||
}
|
||||
|
||||
$bundle_documents = $bundle_item['wiaas_delivery_documents'];
|
||||
$bundle_documents = $bundle_item->get_meta('_wiaas_documents', true);
|
||||
if (empty($bundle_documents)) {
|
||||
$bundle_documents = array();
|
||||
}
|
||||
@@ -140,15 +140,20 @@ class Wiaas_Order_Fields {
|
||||
foreach ($added_documents as $added_document) {
|
||||
$info = pathinfo( $added_document );
|
||||
|
||||
$dir = wp_upload_dir();
|
||||
$relative_file_path = str_replace($dir['baseurl'] . '/', '', $added_document);
|
||||
|
||||
$bundle_documents[] = array(
|
||||
'name' => $info['basename'],
|
||||
'key' => wp_generate_uuid4(),
|
||||
'name' => $info['filename'],
|
||||
'extension' => $info['extension'],
|
||||
'version' => $relative_file_path,
|
||||
'url' => $field->get_download_url( $added_document, true ),
|
||||
'type' => $field->wiaasDocTypeFilter
|
||||
);
|
||||
}
|
||||
|
||||
$bundle_item->update_meta_data('wiaas_delivery_documents', $bundle_documents);
|
||||
$bundle_item->update_meta_data('_wiaas_documents', $bundle_documents);
|
||||
$bundle_item->save_meta_data();
|
||||
|
||||
break;
|
||||
@@ -168,7 +173,7 @@ class Wiaas_Order_Fields {
|
||||
$added_documents = $new_documents;
|
||||
}
|
||||
|
||||
$order_documents = $order->get_meta('wiaas_delivery_documents', true);
|
||||
$order_documents = $order->get_meta('_wiaas_other_documents', true);
|
||||
if (empty($order_documents)) {
|
||||
$order_documents = array();
|
||||
}
|
||||
@@ -176,15 +181,20 @@ class Wiaas_Order_Fields {
|
||||
foreach ($added_documents as $added_document) {
|
||||
$info = pathinfo( $added_document );
|
||||
|
||||
$dir = wp_upload_dir();
|
||||
$relative_file_path = str_replace($dir['baseurl'] . '/', '', $added_document);
|
||||
|
||||
$order_documents[] = array(
|
||||
'name' => $info['basename'],
|
||||
'key' => wp_generate_uuid4(),
|
||||
'name' => $info['filename'],
|
||||
'extension' => $info['extension'],
|
||||
'version' => $relative_file_path,
|
||||
'url' => $field->get_download_url( $added_document, true ),
|
||||
'type' => $field->wiaasDocTypeFilter
|
||||
);
|
||||
}
|
||||
|
||||
$order->update_meta_data('wiaas_delivery_documents', $order_documents);
|
||||
$order->update_meta_data('_wiaas_other_documents', $order_documents);
|
||||
$order->save_meta_data();
|
||||
|
||||
break;
|
||||
@@ -216,7 +226,7 @@ class Wiaas_Order_Fields {
|
||||
continue;
|
||||
}
|
||||
|
||||
$bundle_item->update_meta_data('wiaas_installation', $selected_installation->get_id());
|
||||
$bundle_item->update_meta_data('_wiaas_installation', $selected_installation->get_id());
|
||||
$bundle_item->save_meta_data();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user