p.s. the code given to me @ the time was this:
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'minnoe_ordernotes_custom_checkout_field');
function minnoe_ordernotes_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('Delivery Date').'</h3>';
woocommerce_form_field( 'delivery_date_name', array(
'type' => 'text', 'class' => array('delivery-date-class form-row-wide'),
'label' => __('Eg. Tues, July 22.'),
'placeholder' => __('Date of Delivery'),
), $checkout->get_value( 'my_field_name' ));
echo '</div>';
}
/**
* Process the checkout
**/add_action('woocommerce_checkout_process', 'minnoe_delivery_custom_checkout_field_process');
function minnoe_delivery_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if (!$_POST['delivery_date_name'])
$woocommerce->add_error( __('Please enter delivry date.') );
}
/** * Update the order meta with field value
**/
add_action('woocommerce_checkout_update_order_meta', 'minnoe_delivery_custom_checkout_field_update_order_meta');
function minnoe_delivery_custom_checkout_field_update_order_meta( $order_id ) {
if ($_POST['delivery_date_name']) update_post_meta( $order_id, 'Delivery Date', esc_attr($_POST['delivery_date_name']));
}
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'minnoe_notes_custom_checkout_field');
function minnoe_notes_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('Recipeint Phone').'</h3>';
woocommerce_form_field( 'recipient_phone_name', array(
'type' => 'text', 'class' => array('recipient-phone-class form-row-wide'),
'label' => __('Home & or Cell'),
'placeholder' => __('Both numbers would be great!'),
), $checkout->get_value( 'recipeint_phone_name' ));
echo '</div>';
}
/**
* Process the checkout
**/add_action('woocommerce_checkout_process', 'minnoe_custom_checkout_field_process');
function minnoe_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if (!$_POST['recipeint_phone_name'])
$woocommerce->add_error( __('Please enter phone number.') );
}
/** * Update the order meta with field value
**/
add_action('woocommerce_checkout_update_order_meta', 'minnoe_custom_checkout_field_update_order_meta');
function minnoe_custom_checkout_field_update_order_meta( $order_id ) {
if ($_POST['delivery_date_name']) update_post_meta( $order_id, 'Recipient Phone', esc_attr($_POST['my_field_name']));
}