diff --git a/backend/app/plugins/wiaas/includes/api/class-wiaas-support-api.php b/backend/app/plugins/wiaas/includes/api/class-wiaas-support-api.php index 627e5eb..475d0f2 100644 --- a/backend/app/plugins/wiaas/includes/api/class-wiaas-support-api.php +++ b/backend/app/plugins/wiaas/includes/api/class-wiaas-support-api.php @@ -14,7 +14,7 @@ class Wiaas_Support_Api { public static function register_routes() { - register_rest_route(self::$namespace, self::$rest_base . '/sendSupportMail', array( + register_rest_route(self::$namespace, self::$rest_base . '/send-support-email', array( 'methods' => 'POST', 'callback' => array(__CLASS__, 'send_support_email'), 'permission_callback' => 'is_user_logged_in', @@ -26,7 +26,7 @@ class Wiaas_Support_Api { 'required' => true, 'sanitize_callback' => 'absint', ), - 'supportText' => array( + 'support_text' => array( 'description' => __('Email text.', 'wiaas'), 'type' => 'string', 'required' => true @@ -45,18 +45,22 @@ class Wiaas_Support_Api { public static function send_support_email($request) { $order_id = $request['id']; - $message = $request['supportText']; + $message = $request['support_text']; + $order = wc_get_order($order_id); + $customer_id = $order->get_customer_id(); + $customer = get_user_by('id', $customer_id); + $mailer = WC()->mailer(); $recipient = WIAAS_SUPPORT_EMAIL; - $subject = __("Customer comment for order id: ".$order_id); + $subject = __('Customer: '.$customer->get('first_name').', '.''.$customer->get('last_name').' needs support for order number: ' .$order->get_order_number()); $headers = array(); $success = $mailer->send( $recipient, $subject, $message, $headers ); if ($success) { - wc_create_order_note($request['id'] , $message, true ); + wc_create_order_note($order_id , $message, true ); return wiaas_api_notice('EMAIL_SENT', 'success'); } diff --git a/backend/config/application.php b/backend/config/application.php index 32cbb01..b61c083 100644 --- a/backend/config/application.php +++ b/backend/config/application.php @@ -48,6 +48,9 @@ define('DB_CHARSET', 'utf8mb4'); define('DB_COLLATE', ''); $table_prefix = env('DB_PREFIX') ?: 'wp_'; +define( 'WP_DEBUG', true ); +define( 'WP_DEBUG_LOG', true ); + /** * Authentication Unique Keys and Salts */ diff --git a/frontend/src/actions/orders/processActions.js b/frontend/src/actions/orders/processActions.js index b5eebf3..03b9117 100644 --- a/frontend/src/actions/orders/processActions.js +++ b/frontend/src/actions/orders/processActions.js @@ -325,13 +325,13 @@ export const setSupportMessage = (message) => ({ supportText: message }); -export const sendSupportMail = (orderInfo, orderPackages, supportText) => { +export const sendSupportMail = (orderInfo, orderPackages, support_text) => { let id = orderInfo.id; return dispatch => { return htmlClient.fetch({ - url: `${API_SERVER}/wp-json/wiaas/support/sendSupportMail`, + url: `${API_SERVER}/wp-json/wiaas/support/send-support-email`, method: 'post', - data: {id, supportText} + data: {id, support_text} }) .then(response => { if (typeof response.data !== 'undefined' && 'messages' in response.data) {