update_post_meta is not working for saving info
-
Hello everyone, hope you can help me. I have used this code:
add_action( ‘woocommerce_before_checkout_form’, ‘my_custom_checkout_field’ );function my_custom_checkout_field( $checkout ) {
echo ‘<div id=”my_custom_checkout_field”><h2>’ . __(‘cedulacliente’) . ‘</h2>’;
woocommerce_form_field( ‘ced’, array(
‘type’ => ‘text’,
‘required’ => true,
‘class’ => array(‘form-row-wide’),
‘label’ => __(‘Cédula o RUC’),
‘placeholder’ => __(‘Cédula o RUC’),
), $checkout->get_value( ‘cedulacliente’ ));echo ‘</div>’;
}
add_action(‘woocommerce_checkout_update_order_meta’,’my_custom_checkout_field_save_additional_fields’);
function my_custom_checkout_field_save_additional_fields( $order_id ) {
if ( ! empty( $_POST[‘cedulacliente’] ) ) {
update_post_meta( $order_id, ‘cedulacliente’, sanitize_text_field( $_POST[‘cedulacliente’] ) );
}
}In order to create an additional field I needed for my website, but it is not retrieving any meta info, so I cannot extract the information I need from that custom field.
¿Can anyone help me with this, please?
Thanks in advance!!
-
Hello there,
Many thanks for reaching out.
Are you able to confirm the URL of the website that you need assistance with please?
Please note that we can only assist with sites on WordPress.com.
I hope this helps.
- The topic ‘update_post_meta is not working for saving info’ is closed to new replies.