How To Add Custom Order Fields To Orders Table In Database.

I'm new to addon development and am trying to add a new field to the notes section of the checkout like so:

in notes.pre.tpl:

{__("dd_title")}

{__("dd_message")}

In my func.php file I have:

function fn_delivery_date_place_order($order_id, $action, $order_status, $cart, $auth)
{
    if(!empty($cart['delivery_date'])){
        db_query('UPDATE ?:orders SET ?u WHERE order_id = ?i', array(
            'delivery_date' =>$cart['delivery_date']
        ), $order_id);
    }
}

the function runs but $cart['delivery_date']; is empty when i submit the order, I'm clearly missing a step.

I have a new column "delivery_date" int the orders table in the database. Could someone please suggest what additional steps I'd need to take to add my custom field into this column in the orders table?

Notes value is added to the cart array in the fn_checkout_update_steps (app/functions/fn.cart.php) function:

    if (!empty($params['customer_notes'])) {
        $cart['notes'] = $params['customer_notes'];
    }

You should use the same logic. In this case even the fn_delivery_date_place_order is not required. Just add the delivery_date field to cscart_orders table

Notes value is added to the cart array in the fn_checkout_update_steps (app/functions/fn.cart.php) function:

    if (!empty($params['customer_notes'])) {
        $cart['notes'] = $params['customer_notes'];
    }

You should use the save logic. In this case even the fn_delivery_date_place_order is not required. Just add the delivery_date field to cscart_orders table

Excellent thanks. I'll give that a try.

If you have the delivery date in a smarty variable aready, then do't modify core files, use the 'final_section_customer_notes' hook to add your display below the customer notes.