So I was able to limit the zip code length limit to 5 on the user's shipping/billing info on their account page as well as the checkout page using this code in my functions.php:
function my_wc_custom_billing_fields( $fields ) {
$fields['billing_postcode']['maxlength'] = 5;
return $fields;
}
add_filter( 'woocommerce_billing_fields', 'my_wc_custom_billing_fields' );
function my_wc_custom_shipping_fields( $fields ) {
$fields['shipping_postcode']['maxlength'] = 5;
return $fields;
}
add_filter( 'woocommerce_shipping_fields', 'my_wc_custom_shipping_fields' );
However, I still am able to enter past the limit in the zip code box on the CART page. You are able to change your address on the cart page and if you click "go to checkout" after typing more than 5 digits, it will allow the form to fill in with those additional digits on the checkout page. I want the zip code box on the CART page to work the same as it does on the other pages.
Thank you for taking to the time to read this. I hope to hear from someone soon!
------- >EDIT: FIGURED IT OUT!
Instead of creating a filter inside my functions.php, I directly edited the woocommerce/templates/cart/shipping-calculator.php file.
In this piece of code:
<?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_postcode', true ) ) : ?>
<p class="form-row form-row-wide" id="calc_shipping_postcode_field">
<input type="text" class="input-text" value="<?php echo esc_attr( WC()->customer->get_shipping_postcode() ); ?>" placeholder="<?php esc_attr_e( 'Postcode / ZIP', 'woocommerce' ); ?>" name="calc_shipping_postcode" id="calc_shipping_postcode" />
</p>
<?php endif; ?>
I simply added "maxlength="5" in the line.
<input type="text" class="input-text" maxlength="5" value="
I hope this helps someone along the way! :)