Solution found:
The file 'order.php' processes the order details from multiple sources (shipping, customer, order) etc... and puts all this together for the final processing. However "Comments" and our new field "gift_message" are stored in sessions.
So, at the point of trying to extract the data from the orders table, the 'gift_message' and 'comments' had not actually been UPDATED into the database. So, indeed, the field empty.
Therefore, we needed to find the session details.
Regretfully, there were many session variables with arrays within them (so we couldn't just do a session dump) and we had no idea as to what these were or what the $key values were so we couldn't extract them.
We were looking for 'gift_message'... and tried a load of stuff like $_SESSION['shipping']['gift_message'] etc to try and find where the gift message was stored. We knew it had to be in a session.
In the end we realised that the field in the checkout was actually called 'gift-message' and tried that
$_SESSION['gift-message']
Bingo...
Great naming policy from Numinix there !!
So, we added the line...
Code:
'gift_message' => $_SESSION['gift-message'],
to :
Code:
LINE 350 (approx)...
$this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,
'currency' => $_SESSION['currency'],
'currency_value' => $currencies->currencies[$_SESSION['currency']]['value'],
'payment_method' => $GLOBALS[$class]->title,
'payment_module_code' => $GLOBALS[$class]->code,
'coupon_code' => $coupon_code->fields['coupon_code'],
// 'cc_type' => (isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : ''),
// 'cc_owner' => (isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : ''),
// 'cc_number' => (isset($GLOBALS['cc_number']) ? $GLOBALS['cc_number'] : ''),
// 'cc_expires' => (isset($GLOBALS['cc_expires']) ? $GLOBALS['cc_expires'] : ''),
// 'cc_cvv' => (isset($GLOBALS['cc_cvv']) ? $GLOBALS['cc_cvv'] : ''),
'shipping_method' => (is_array($_SESSION['shipping']) ? $_SESSION['shipping']['title'] : $_SESSION['shipping']),
'shipping_module_code' => (isset($_SESSION['shipping']['id']) && strpos($_SESSION['shipping']['id'], '_') > 0 ? $_SESSION['shipping']['id'] : $_SESSION['shipping']),
'shipping_cost' => $_SESSION['shipping']['cost'],
'subtotal' => 0,
'shipping_tax' => 0,
'tax' => 0,
'total' => 0,
'tax_groups' => array(),
'comments' => (isset($_SESSION['comments']) ? $_SESSION['comments'] : ''),
'gift_message' => $_SESSION['gift-message'],
'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR']
);
And then (approx Line 1200)
Code:
if ($this->info['gift_message'])
{
$email_order .= zen_db_output($this->info['gift_message']) . "\n\n";
$html_msg['PREFERRED_DELIVERY_DATE'] = nl2br(zen_db_output($this->info['gift_message']));
}
else
{
$html_msg['PREFERRED_DELIVERY_DATE'] = 'No Results found in session for the gift_message';
}
Hope this helps someone !!
We had already added in $html_msg['PREFERRED_DELIVERY_DATE'] successfully to the HTML email template.
Bookmarks