From b02f0881d3a07e7f4d51e0a79e6dada8fd3f6c89 Mon Sep 17 00:00:00 2001 From: Almira Krdzic Date: Mon, 5 Nov 2018 10:53:54 +0100 Subject: [PATCH] Fix customer acceptance flow --- .../includes/class-wiaas-delivery-process.php | 12 ------------ .../class-wiaas-delivery-process-action.php | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php b/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php index 160dcec..8815b95 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php @@ -201,11 +201,6 @@ class Wiaas_Delivery_Process { $action_entry = $action_entries[0]; Wiaas_Delivery_Process_Action::update_customer_acceptance_status($action_entry['id'], $status, $reason); - - if ($status === 'accept') { - - Wiaas_Delivery_Process_Action::complete_action_step($action_entry['id']); - } } } @@ -232,8 +227,6 @@ class Wiaas_Delivery_Process { public static function upload_customer_questionnaire($order_id, $action_entry_id) { Wiaas_Delivery_Process_Action::upload_customer_questionnaire($action_entry_id); - - Wiaas_Delivery_Process_Action::complete_action_step($action_entry_id); } public static function upload_customer_acceptance_document($order_id) { @@ -252,11 +245,6 @@ class Wiaas_Delivery_Process { $success = Wiaas_Delivery_Process_Action::upload_customer_acceptance_document($action_entry['id']); - if ($success) { - - Wiaas_Delivery_Process_Action::complete_action_step($action_entry['id']); - } - return $success; } diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-action.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-action.php index 5ea5d6b..2917221 100644 --- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-action.php +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-action.php @@ -181,6 +181,8 @@ class Wiaas_Delivery_Process_Action { $action_entry[$document_field->id] = $new_file; GFAPI::update_entry($action_entry); + + self::complete_action_step($action_entry_id); } /** @@ -221,12 +223,10 @@ class Wiaas_Delivery_Process_Action { GFAPI::update_entry($action_entry); - $workflow = new Gravity_Flow_API($action_form['id']); - $current_step = $workflow->get_current_step($action_entry); + if ($new_status === 'accept') { - if ($current_step && $current_step->get_t) - - Wiaas_Delivery_Process_Action::complete_action_step($action_entry['id']); + Wiaas_Delivery_Process_Action::complete_action_step($action_entry['id']); + } } /** @@ -267,6 +267,15 @@ class Wiaas_Delivery_Process_Action { $result = GFAPI::update_entry($action_entry); + // complete step if current step is customer acceptance user input + $workflow = new Gravity_Flow_API($action_form['id']); + $current_step = $workflow->get_current_step($action_entry); + + if ($current_step->get_type() === 'user_input' && ! is_wp_error($result)) { + + Wiaas_Delivery_Process_Action::complete_action_step($action_entry['id']); + } + return ! is_wp_error($result); }