Hi. Thanks so much for the reply.
The user first registers where they can save the details for 2 prisoners and numbers. (user_meta: prisoner_1 and prisoner_1_number).
Then they login and choose a date and time, and in the checkout page they choose which prisoner they want to visit online.
I use a code snippet to collect that information in checkout page:
add_action(‘woocommerce_before_order_notes’, ‘wps_add_select_checkout_field’);
function wps_add_select_checkout_field( $checkout ) {
// Get Current User
$user_id = get_current_user_id();
// Setup Variable Values from Metadata
$pris_1 = get_user_meta( $user_id, ‘prisoner_1’, true ) . ‘ – ‘ . get_user_meta( $user_id, ‘prisoner_1_number’, true );
$pris_2 = get_user_meta( $user_id, ‘prisoner_2’, true ) . ‘ – ‘ . get_user_meta( $user_id, ‘prisoner_2_number’, true );
// Select Prisoner PHP Code
echo ‘<h2>’.__(‘????????????????????’).'</h2>’;
woocommerce_form_field( ‘prisoner’, array(
‘type’ => ‘select’,
‘class’ => array( ‘wps-drop’ ),
‘label’ => __( ‘???????????????????????????’ ),
‘options’ => array(
‘blank’ => __( ‘???????????????’, ‘wps’ ),
$pris_1 => __( $pris_1, ‘wps’ ),
$pris_2 => __( $pris_2, ‘wps’ ),
)
),
$checkout->get_value( ‘prisoner’ ));
}
And it is saved with the following snippet:
add_action(‘woocommerce_checkout_update_order_meta’, ‘wps_select_checkout_field_update_order_meta’);
function wps_select_checkout_field_update_order_meta( $user_id ) {
if ($_POST[‘prisoner’]) update_post_meta( $user_id, ‘prisoner’, esc_attr($_POST[‘prisoner’]));
}
I have a stage site but not sure if I can post admin access details here.
https://cida.site/dev2