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 3e02d21..b459820 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php @@ -42,6 +42,9 @@ class Wiaas_Delivery_Process { require_once( 'delivery-process/class-wiaas-field-order-document.php' ); require_once( 'delivery-process/class-wiaas-field-order-bundle-installation-date.php' ); + // merge tags (for emails) + require_once( 'delivery-process/class-wiaas-merge-tag-customer-order-url.php' ); + Gravity_Flow_Steps::register( new Wiaas_Delivery_Process_Step() ); GFAddOn::register( 'Wiaas_Delivery_Process_Addon' ); diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-merge-tag-customer-order-url.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-merge-tag-customer-order-url.php new file mode 100644 index 0000000..14889ff --- /dev/null +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-merge-tag-customer-order-url.php @@ -0,0 +1,59 @@ +get_matches( $text ); + + if ( ! empty( $matches ) ) { + + $entry = $this->entry; + + $form = GFAPI::get_form($entry['form_id']); + + $order_field = GFCommon::get_fields_by_type($form, 'wiaas_order')[0]; + + if (empty($order_field)) { + + return $text; + } + + $order_id = $entry[$order_field->id]; + + $url = WIAAS_CUSTOMER_INTERFACE . '/orders/' . $order_id; + + $link = sprintf( '%s', $url, 'Order' ); + + foreach ( $matches as $match ) { + $full_tag = $match[0]; + + $text = str_replace( $full_tag, $link, $text ); + } + } + + return $text; + } +} + +Gravity_Flow_Merge_Tags::register( new Wiaas_Merge_Tag_Customer_Order_Url ); \ No newline at end of file