Wednesday, September 7, 2022
HomeWordPress DevelopmentWoocommerce not saving customized discipline

Woocommerce not saving customized discipline


Mainly, I’ve a perform which ought to add customized fields relying on a cart amount.

Nevertheless it wasn’t working. I began debugging and that is my perform and it would not save posted customized discipline and I am unable to determine why.

add_action('woocommerce_after_checkout_billing_form', 'custom_checkout_field');
perform custom_checkout_field($checkout){
    echo '<div><h4>Passenger</h4>';
        woocommerce_form_field('passenger_birthdate_2', array(
            'kind'        => 'textual content',
            'label'       => 'Date of start',
            'required'    => true,
        ),
        $checkout->get_value('passenger_birthdate_2'));
    echo '</div>';
}

add_action('woocommerce_checkout_update_order_meta', 'custom_checkout_field_update_order_meta');
perform custom_checkout_field_update_order_meta( $order_id ) {
    if ($_POST['passenger_birthdate_2']) update_post_meta($order_id, 'passenger_birthdate_2', sanitize_text_field($_POST['passenger_birthdate_2']));
}

Am I lacking one thing?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments