Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support krzysztofskorupa

    (@krzysztofskorupa)

    Hi,
    thank you very much for your contact.

    Each country has a different number of digits and these values are determined by WooCommerce.
    What would you like to achieve?
    Perhaps I can direct you to some other solution :).
    Greetings,

    Thread Starter daszvetco

    (@daszvetco)

    We only do USA. Our EDI system will only allow 5 digit zip for credit card processing, so I want to limit the ZIP field to 5 digits max

    Plugin Support krzysztofskorupa

    (@krzysztofskorupa)

    <?php
    // Do NOT include the opening php tag

    /**
    * Function to validate the length
    *
    */
    function wpdesk_fcf_validate_length( $field_label, $value ) {
    $min_length = 3;
    $max_length = 20;
    $value_length = strlen( $value );

    if ( $value_length < $min_length || $value_length > $max_length ) {
    wc_add_notice( sprintf( '%s is not valid. The length must be between %s and %s characters.', '<strong>' . $field_label . '</strong>', $min_length, $max_length ), 'error' );
    }
    }

    add_filter( 'flexible_checkout_fields_custom_validation', 'wpdesk_fcf_custom_validation_length' );
    /**
    * Add custom length validation
    *
    */
    function wpdesk_fcf_custom_validation_length( $custom_validation ) {
    $custom_validation['length'] = array(
    'label' => 'Length',
    'callback' => 'wpdesk_fcf_validate_length'
    );

    return $custom_validation;
    }

    Hi, please check this filter above.

    Adapt it to your needs.
    That is, in your case, change the maximum character length to 5.
    Once you have modified it, enter the relevant field on Checkout and enable validation.

    If there are any further questions, please do not hesitate to contact me. ??

    Best regards,

    Plugin Support krzysztofskorupa

    (@krzysztofskorupa)

    Hello,

    I haven’t heard from you in a while, so I’m marking this thread as resolved. Please don’t hesitate to open a new one if you encounter other issues while using our plugin.

    Have a fantastic day,

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.