Use order notes for comments

This commit is contained in:
Almira Krdzic
2018-08-26 17:23:33 +02:00
committed by GotPPay
parent bd1d8f2103
commit 54e6495795
6 changed files with 88 additions and 33 deletions

View File

@@ -23,6 +23,8 @@ class Wiaas_Delivery_Process {
add_filter( 'gform_entry_meta', array(__CLASS__, 'extend_gravity_form_entry_meta'), 10, 2 );
add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_process_step'), 5, 3 );
add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_order'), 10, 3 );
}
/**
@@ -34,6 +36,29 @@ class Wiaas_Delivery_Process {
Gravity_Flow_Steps::register( new Wiaas_Delivery_Process_Step() );
}
/**
* Maybe complete parent order for completed delivery process
* @param $entry_id
* @param $form
*/
public static function maybe_complete_parent_order($entry_id, $form) {
$entry = GFAPI::get_entry($entry_id);
$order_id = $entry['wiaas_delivery_order_id'];
if (!isset($order_id)) {
return;
}
$process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id', true);
// order process entry completed, so complete order
if (absint($process_entry_id) === $entry_id) {
$order = wc_get_order($order_id);
$order->update_status('completed', 'Completed order delivery process.', true);
}
}
/**
* Retrieves delivery process instance for order
*