• Resolved Anonymous User 15528382

    (@anonymized-15528382)


    Some custom validation (and related notices/errors) are not working properly from checkout only if Stripe is selected.

    This happens to custom fields and regular fields (e.g. Order Notes).

    You can test this in your functions.php:

    // Validate a field from checkout testing with Stripe
    function checkout_order_comments_required() {
        if ( isset( $_POST['order_comments'] ) && empty($_POST['order_comments']) ) {
    		wc_add_notice( sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . __( 'Order notes', 'woocommerce' ) . '</strong>' ) ,'error' );
    	}
    }
    add_action( 'woocommerce_checkout_process', 'checkout_order_comments_required' );

    Related: https://docs.woocommerce.com/wc-apidocs/function-wc_add_notice.html

    The fields are not validated until all fields where completed and correct payment data filled.

    Later, the fields are validated and show in correct language, e.g.:
    Notas del pedido es un campo requerido.

    This works correct with other payment methods and with 3.2.3 version.

    Does Stripe omit the validation of WC fields and validate the fields itself? It is necessary?

    Thanks!

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author royho

    (@royho)

    In my test, this is what I see http://cld.wthms.co/FBfvV5

    Thread Starter Anonymous User 15528382

    (@anonymized-15528382)

    Hmmm I see in your screenshot “%s is a required field” translated, maybe this is related to the translation bug that has been corrected in your wip 4.0.1 (I’m in 4.0.0).

    Plugin Author royho

    (@royho)

    The translation yes however I was under the impression you meant no errors show. That is how I understand what you wrote.

    Thread Starter Anonymous User 15528382

    (@anonymized-15528382)

    If you tested my function with wip 4.0.1, maybe this bug was alredy corrected.

    In my 4.0.0, these fields are not validated until all fields where completed and correct payment data filled…

    I’m trying to do my best, thanks!

    Thread Starter Anonymous User 15528382

    (@anonymized-15528382)

    I’ve tried github updated version and works perfect. Like I said (I don’t know why) this bug was related to translation too.

    Thanks for your work, I’ll wait to 4.0.1 to update. don’t work.

    Like I said before that field are not validated until all fields where completed and correct payment data filled…

    Thanks.

    • This reply was modified 6 years, 3 months ago by Anonymous User 15528382. Reason: not resolved, sorry
    Plugin Author royho

    (@royho)

    Sorry I don’t know how to help as I can’t reproduce it and I don’t know how you have your site setup.

    Thread Starter Anonymous User 15528382

    (@anonymized-15528382)

    Just reproduced the bug in test site. Code added directly to Storefront functions.php, and inserted fake API data (don’t fill card data).

    You can test here:
    http://elegant-koala.w6.poopy.life/?add-to-cart=38

    Login: http://elegant-koala.w6.poopy.life/wp-admin/
    Username: (poopy.life sandbox)
    Password: (poopy.life sandbox)

    Don’t fill any field and try to place order with Check payments and Stripe, and compare error notices.

    Plugin Author royho

    (@royho)

    I would suggest you remove the login for security reasons.

    Plugin Author royho

    (@royho)

    Ok I see what you’re saying but its ok for you to have to fill everything before validation and is expected. Because the forms are separate in 4.0, WC and Stripe each have their own validations.

    Thread Starter Anonymous User 15528382

    (@anonymized-15528382)

    In that case, the user has a different experience, within the same form. Maybe the user should see all the errors together, as WC and other payment methods does.
    Also, the text notices are different from the WC standard.
    Is it necessary for Stripe to validate and wrote separately and in a different way?
    Thank you!

    Plugin Author royho

    (@royho)

    Also you’re using wrong hook. You should use something like this.

    
    function checkout_order_comments_required( $fields ) {
        $fields['order']['order_comments']['required'] = 1;
    
        return $fields;
    }
    add_filter( 'woocommerce_checkout_fields', 'checkout_order_comments_required' );
    
    • This reply was modified 6 years, 3 months ago by royho.
    Thread Starter Anonymous User 15528382

    (@anonymized-15528382)

    Thanks for the hook!

    About my last message, it would be better to act the same, but at least and to keep the WC style:

    Can the names of the fields be in bold in the notices?

    Thread Starter Anonymous User 15528382

    (@anonymized-15528382)

    For show the field name bold on errors and use WooCommerce text (UX homogenization):

    class-wc-stripe-order-handler.php you can replace line 394 with:

    $errors->add( 'validation', sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>'.$error_field.'</strong>' ) );

    Plugin Author royho

    (@royho)

    I will investigate this more in the next couple weeks and see if I can find a solution.

    Thread Starter Anonymous User 15528382

    (@anonymized-15528382)

    Thanks!!!

    Tell me if I can test/help with that πŸ™‚

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Stripe wrong custom checkout validation/notices (v.4.0.0)’ is closed to new replies.