foreach($orderItems as $orderItem){
$orderItemsAsString .= "<p>" .$orderItem->get_name(). " " . $orderItem->get_quantity() . " <a>". $orderItem->get_meta('pa_url', true) . "</a></p>";
}
$orderItemsAsString .= "<p> via " . $paymentMethod. "</p>";
$orderItemsAsString .= "<p> Total {$order->get_total()}</p>";
// Freshdesk ticket creation
$fd_domain = "";
$token = "";
$password = "";
$data = array(
"helpdesk_ticket" => array(
"description" => $orderItemsAsString,
"subject" => "PopUSocial New Customer Order (#{$order_id}) ",
"email" => $order->get_billing_email(),
"priority" => 1,
"status" => 2
)
);
// $json_body = json_encode($data, JSON_FORCE_OBJECT | JSON_PRETTY_PRINT);
$json_body = json_encode($data);
$headerd] = "Content-type: application/json";
$connection = curl_init("$fd_domain/helpdesk/tickets.json");
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connection, CURLOPT_HTTPHEADER, $header);
curl_setopt($connection, CURLOPT_HEADER, false);
curl_setopt($connection, CURLOPT_USERPWD, "$token:$password");
curl_setopt($connection, CURLOPT_POST, true);
curl_setopt($connection, CURLOPT_POSTFIELDS, $json_body);
curl_setopt($connection, CURLOPT_VERBOSE, 1);
$response = curl_exec($connection);
As you can see above, I am constructing the order items by adding each order's details inside paragraph tags. When the ticket is created the description isn't properly formatted HTML but plain text that outputs every tag as it is.
Here's the snapshot of the ticket