From 24e8515b302ab4e428c6f39a97b3876e7cc2d57f Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Sat, 3 Nov 2018 07:13:30 +0100 Subject: [PATCH] show link to delivery process page --- .../class-wiaas-admin-delivery-process-flow.php | 5 +++-- .../includes/class-wiaas-delivery-process.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-flow.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-flow.php index bb43021..b138e65 100644 --- a/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-flow.php +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-flow.php @@ -55,10 +55,11 @@ class Wiaas_Admin_Order_Process_Flow { echo ''; }else{ - $workflow_url = ""; + $current_step = Wiaas_Delivery_Process::get_active_step($order_id); + $workflow_url = $current_step->get_entry_url(); echo '
- Go to process flow + Go to delivery process page
'; } } 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 328a2d0..9e9a4de 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php @@ -98,6 +98,22 @@ class Wiaas_Delivery_Process { return $result; } + public static function get_active_step($order_id){ + $process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id'); + if (empty($process_entry_id)) { + return null; + } + + $process_instance = GFAPI::get_entry($process_entry_id); + $api = new Gravity_Flow_API($process_instance['form_id']); + $steps_info = $api->get_steps(); + + foreach ( $steps_info as $step_info ) { + return $api->get_step( $step_info->get_id(), $process_instance ); + } + return null; + } + /** * Retrieves delivery process instance for order *