Enable admin to enter installation date on delivery process:
:
This commit is contained in:
@@ -76,6 +76,33 @@ class Wiaas_Order_Fields {
|
||||
// save changes to order
|
||||
switch ($field->type) {
|
||||
|
||||
case 'wiaas_order_bundle_installation_date':
|
||||
/**
|
||||
* Persist bundle installation date
|
||||
*/
|
||||
|
||||
// get corresponding bundle field
|
||||
$bundle_field = GFCommon::get_fields_by_type( $form, 'wiaas_order_bundle' )[0];
|
||||
|
||||
if (empty($bundle_field)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$bundle_item = $bundle_field->get_bundle_item( $entry[$bundle_field->id] );
|
||||
|
||||
if (empty($bundle_item)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
error_log($new_value);
|
||||
|
||||
$bundle_item->update_meta_data('wiaas_installation_date', $new_value);
|
||||
$bundle_item->save_meta_data();
|
||||
|
||||
break;
|
||||
|
||||
case 'wiaas_order_bundle_document':
|
||||
/**
|
||||
* Persist delivery flow documents for bundle
|
||||
@@ -171,7 +198,7 @@ class Wiaas_Order_Fields {
|
||||
|
||||
$selected_installation = $field->get_selected_installation($new_value);
|
||||
|
||||
if (empty($selected_installation)) {
|
||||
if ( empty($selected_installation) ) {
|
||||
// no installation selected
|
||||
continue;
|
||||
}
|
||||
@@ -394,6 +421,14 @@ class Wiaas_Order_Fields {
|
||||
return false;
|
||||
}
|
||||
|
||||
// installation is already selected
|
||||
if (!empty($bundle_item->get_meta('wiaas_installation', true))) {
|
||||
|
||||
$entry[(string) $field->id] = 'wiaas_installation_' . $order->get_id() . '|' . $bundle_item->get_meta('wiaas_installation', true);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$bundled_items = wc_pb_get_bundled_order_items($bundle_item, $order);
|
||||
|
||||
$installation_items = array();
|
||||
@@ -408,7 +443,7 @@ class Wiaas_Order_Fields {
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($installation_items) && $field->isRequired) {
|
||||
if (empty($installation_items)) {
|
||||
// there is no data for required field so entry cannot be created
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user