Okay
  Public Ticket #1633620
mandatory field issue on checkout page
Closed

Comments

  • mananpanchali started the conversation

    Hello Team,

    Mandatory field validation for checkout page seems not working. it is only working for Postcode/ZIP. It is allowing to place order without putting name/address/phone number and other * - mandatory fields. Could you please provide fix for the same? Let us know if your require any other details to understand the issue.

    Please check the attached screenshot. The firstname field is not entered, but it is not giving any errors. Other fields are also behaving the same except Postcode/ZIP.

    Thank you.

  •  604
    WordPress replied

    Hi,

    Sorry for late reply.
    I'm checking it for you.


    Thanks!

    Alex Vũ


  • mananpanchali replied

    Any Luck Alex?

  •  604
    WordPress replied

    Hi,

    You can install and active child theme. Then, you can copy code file function.php in child theme and save

    function remove_parent_filters(){
        remove_filter('woocommerce_checkout_fields', 'aki_custom_override_checkout_fields');
        remove_filter("woocommerce_checkout_fields", "aki_order_fields");
        remove_filter("woocommerce_checkout_fields", "aki_order_shipping_fields");
    }
    add_action( 'after_setup_theme', 'remove_parent_filters' );
    Thanks!

    Alex Vũ



  • mananpanchali replied

    Hello Alex,

    Thank you for the response. After adding the code you gave few more fields are working as expected, but street address field is still not mandatory even though it has to be required. Please find my child theme function.php file attached to the post.

    Awaiting your reply.

    Regards.

  •  604
    WordPress replied

    Hello,

    Can you provide an admin account info so I can check for your problem?

    Thanks!

    Alex Vu


  • mananpanchali replied

    Ok. I will send you details tonight.

  •   mananpanchali replied privately
  •  604
    WordPress replied

    Hi,

    I have checked and checkout page has required field.


    Thanks!

    Alex Vũ


  • mananpanchali replied

    Hi Alex,

    Agreed, but we need billing/shipping address also as mandatory. They showed * but it is not getting validated

  •  604
    WordPress replied

    Hi,

    You can  add code file function.php in child theme

    add_filter( 'woocommerce_default_address_fields' , 'aki_override_default_address_fields' );
    function aki_override_default_address_fields( $address_fields ) {
        $address_fields['address_1']['placeholder'] = '';
        $address_fields['address_1']['required'] = true;     return $address_fields;
    }
    Thanks!

    Alex Vũ



  • mananpanchali replied

    Hello Alex,

    Thank you, for the suggestion. We tried it, however as soon as we save the functions.php file in our child theme, we get 500 error on our site homepage.

    Please check the php file attached with this post and also the screenshot of the error.

    Regards.

  •  604
    WordPress replied

    Hi,

    Sorry for late reply.
    I solved that problem you can check back.

    Thanks!

    Alex Vũ



  • mananpanchali replied

    Hi Alex,

    sorry for coming back late. 

    It seems to be fixed. Also let me know how did you fix that:-) THANKS..

  •  604
    WordPress replied

    Hi,

    I have to reload the functions.php file. You can check the code in file.

    add_filter( 'woocommerce_default_address_fields' , 'aki_override_default_address_fields' );
    function aki_override_default_address_fields( $address_fields ) {
        $address_fields['address_1']['placeholder'] = '';
        $address_fields['address_1']['required'] = true;
        return $address_fields;
    }
    function remove_parent_filters(){
        remove_filter('woocommerce_checkout_fields', 'aki_custom_override_checkout_fields');
        remove_filter("woocommerce_checkout_fields", "aki_order_fields");
        remove_filter("woocommerce_checkout_fields", "aki_order_shipping_fields");
    }
    add_action( 'after_setup_theme', 'remove_parent_filters' );

    Can you take some time to rate our item 5stars in ThemeForest?

    https://themeforest.net/item/aki-multipurpose-wordpress-theme/reviews/20738235

    Thanks
    Alex Vũ