• Resolved Webfolio Webdesign

    (@webreneszansz)


    Hi,

    Because of the specification of the external shipping company, it would be very important to limit the length of the customer name (last name and first name + company name, if any) and address (city + zip code, 2. address line etc.), since their can manage max. only 40 characters for each information. Every longer data result problem, manual modification need and the shop lost a lot of time and money of course because of the additional administration.

    Please be so kind and help to fix the problem, let me know, how can we limit these.

    Thank you very much.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there,

    I understand that you need to limit the length of customer names, addresses, and company details to 40 characters to comply with the external shipping company’s specifications. Currently, WooCommerce does not have built-in functionality to set character limits on these fields directly. However, you can address this issue using custom code or by using third-party plugins.

    You can try to use the following plugin for this purpose.
    https://woocommerce.com/products/custom-checkout-fields-editor/

    Alternatively, I can recommend WooExperts and Codeable.io as options for getting professional help. Alternatively, you can also ask your development questions in the  WooCommerce Community Slack as custom code falls outside our usual scope of support.

    Saif

    (@babylon1999)

    Hello @webreneszansz!

    I’m not sure if you want all fields to be under 40 characters or a 40-character max per field. If the latter, try adding the following snippet to your store via the CodeSnippets plugin.

    add_filter( 'woocommerce_checkout_fields', 'custom_checkout_fields_character_limit', 9999 );

    function custom_checkout_fields_character_limit( $fields ) {
    // Billing Fields
    $fields['billing']['billing_first_name']['maxlength'] = 40;
    $fields['billing']['billing_last_name']['maxlength'] = 40;
    $fields['billing']['billing_company']['maxlength'] = 40;
    $fields['billing']['billing_address_1']['maxlength'] = 40;
    $fields['billing']['billing_address_2']['maxlength'] = 40;
    $fields['billing']['billing_city']['maxlength'] = 40;

    // Shipping Fields
    $fields['shipping']['shipping_first_name']['maxlength'] = 40;
    $fields['shipping']['shipping_last_name']['maxlength'] = 40;
    $fields['shipping']['shipping_company']['maxlength'] = 40;
    $fields['shipping']['shipping_address_1']['maxlength'] = 40;
    $fields['shipping']['shipping_address_2']['maxlength'] = 40;
    $fields['shipping']['shipping_city']['maxlength'] = 40;

    return $fields;
    }

    Thread Starter Webfolio Webdesign

    (@webreneszansz)

    Hi,
    Unfortunately, the checkout field plugins are able to limit the lenghts of the single fields.
    I need to limit the:
    -customer name (toghether the last name and first name + company name, if any) in max. 40 characters
    -and also the address (togheter the city + zip code, 2. address line etc.) in max. 40
    Thank you very much.

    Jonayed (woo-hc)

    (@jonayedhosen)

    Hi @webreneszansz ,

    Thanks for reaching out about this! If your checkout field plugin isn’t giving you an option to set character limits, custom code might be the way to go.

    There’s a helpful snippet shared by @babylon1999 in that thread that does exactly that—it sets a 40-character limit on the fields you need. You can check it out here: https://wordpress.org/support/topic/max-length-of-name-and-address/#post-18450930

    The code covers common checkout fields and should work well as a base.

    Please note that our support is limited to the core WooCommerce plugin, and we’re unable to assist with modifications involving custom code or third-party plugins. For more advanced customizations, I’d recommend reaching out to Codeable or a Certified WooExpert, who can help tailor the solution to your site.

    I hope this helps point you in the right direction.

    Plugin Support Kay U a11n

    (@kingsleyinfo)

    Hi @webreneszansz

    We haven’t heard back from you in a while, so I’m going to mark this as resolved.

    If you have a few minutes, we’d love if you could leave us a review: https://wordpress.org/support/plugin/woocommerce/reviews/

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Max. length of name and address’ is closed to new replies.