I have this snippet which shows a CustomPostType on WooCommerce Checkout Page.
function wps_add_select_checkout_field( $checkout ) {
echo '<h2>'.__('Select a Good Cause').'</h2>';
$args = array(
'post_type' => 'good_cause',
'posts_per_page' => -1,
);
$query = new WP_Query($args);
// Set variable (array)
$options = array();
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
// Add to $options array
$options[get_the_ID()] = get_the_title();
endwhile;
wp_reset_postdata();
endif;
woocommerce_form_field( 'daypart', array(
'type' => 'select',
'class' => array( 'wps-drop' ),
'label' => __( 'Delivery options' ),
'options' => $options
), $checkout->get_value( 'daypart' ));
}
add_action('woocommerce_before_order_notes', 'wps_add_select_checkout_field', 10, 1 );
But this is not stored on the backend, or shown on the email sent to the user or into Order in the user account...
Does anyone know what do I need to add to show this at the backend, display on the emails sent through WP and in the Orders page?