Required custom WooCommerce checkout fields don't validate entered value

后端 未结 3 861
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-27 03:08

I\'m adding WooCommerce custom checkout fields in a Storefront child theme functions.php file.
They have a \"required\" attribute.
The ai

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-27 03:46

    **/* If You Have Created Your Custom Field at the checkout page */**
    
    add_action( 'woocommerce_after_checkout_validation', 'shipping_time_optionss', 9999, 2);
    function shipping_time_optionss( $fields, $errors ){
        // if any validation errors
        if ( empty( $_POST['woo_shipping_time'] ) ) {
            $errors->add( 'woocommerce_password_error', __( 'Please Select Shipping Time Option.' ) );
        } `enter code here`
    } 
    

提交回复
热议问题