By the time woocommerce_checkout_fields
filter is run, the arrays for billing and shipping have already been created.
You can see that here:
https://docs.woothemes.com/wc-apidocs/source-class-WC_Checkout.html#101
If you want to effect the default fields, use this hook.
function wpse215677_checkout_fields ( $fields ) {
$fields['postcode']['maxlength'] = 4;
return $fields;
}
add_filter('woocommerce_default_address_fields', 'wpse215677_checkout_fields');
If you want to adjust just the default billing fields:
function wpse215677_checkout_fields ( $fields ) {
$fields['billing_postcode']['maxlength'] = 4;
return $fields;
}
add_filter('woocommerce_billing_fields', 'wpse215677_checkout_fields');
Otherwise you just need to edit your array declaration:
$fields['billing_postcode']['maxlength'] = 4;
Related Posts:
- Apply jquery script to only woocommerce product pages and categories
- woocommerce target button with class after ajax update
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- Hide ‘add to cart’ when certain value in dropdown is selected
- Execute jQuery with custom event listener after successfully add an item to the cart
- How to create a custom order status in woocommerce!
- How to show product SKU on product page
- How to get woocommerce inventory status [closed]
- Woocommerce add to simple product attribute programmatically [closed]
- In WooCommerce I need to modify the thankyou.php page [closed]
- How can I add an extra WooCommerce hook
- Replacing select2 in admin backend for all selects
- Remove product description from product archive page
- display 100 products per page on product category page [closed]
- jQuery plugin function is not a function
- Adding WooCommerce to a Custom Theme – not working [closed]
- Enqueuing Script in functions.php vs on the page
- Can you use admin pages functionality on the frontend of your site
- Unable to get_the_content(); of a post in WordPress via AJAX
- How to load some jquery code to make validation in the theme customizer?
- Override woocommerce wc-class function
- Display WooCommerce subscriptions for user [closed]
- Increment price for Woocommerce Minicart [closed]
- Change woocommerce products weight varation based its product category or tags? [closed]
- Move jQuery and Migrate to footer?
- Pass parameters to function through an action
- Calling a function from anywhere, used in different places
- Selective Product Category for Carousel
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- Right way to update widget on dynamic new input field
- Not sure if enqueuing js scripts properly
- Load Woocommerce and WordPress Functions Outside
- How to display custom option field in woocommerce orders in admin panel?
- How to add a slide toggle to the Woocommerce-Layout__Activity-Panel area in the orders admin page
- Add to cart php not working [closed]
- How to auto refresh when user change postcode
- How to search using ajax for exact phrase or words in an input field?
- woocommerce change currency per category [closed]
- I can’t enqueue my scripts – They literally aren’t being added to my site
- using jQuery on only one page
- help I changed one currency in woocommerce and everything is ruined [closed]
- How to override woocommerce.css?
- Can’t call Javascript function – scope?
- How can I use Woocommerce $product->get_attribute in functions.php? (if at all)
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- Changing parent element’s class or style
- (Woocommerce) Order by price when entering specific category
- Adding jQuery datepicker to Custom Post Type Metabox [closed]
- In jquery use php variable to execute an enqueued jquery file
- Run a jquery script on on a certain template page
- Add php code to wp_print_scripts?
- How can i unload effect.min.js file?
- wp_enqueue_script | Help me figure out what is causing jQuery is not defined
- add_filter to specific WooCommerce Category
- Woocommerce checkout field
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- Create a Woocommerce product widget with category filter
- How to load jQuery in TOP of wp_footer?
- Passing Jquery value to WordPress function
- WordPress can’t get jquery/unslider to work
- Change WooCommerce add_to_cart Button Text?
- Include Jquery libraries in wordpress theme?
- WooCommerce -> wc_enqueue_js not working [closed]
- Use existing image sizes for WooCommerce
- How to setup a popup registeration page in wordpress with function.php
- Get URLs for AJAX Filter Checkboxes WordPress
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Woocommerce Default sorting product by product type
- wp_set_object_term via js btn frontend
- Change class woocommerce on function.php
- Populate Product Regular Price with a calculated ACF Field Value
- Ajax Form Issues using Lightsail (AWS)
- What is the earliest Hook a Script can use?
- WordPress does not load jQuery
- post value to function with Ajax and jQuery
- When are the user meta fields created in the database? Admin vs Woo API REST
- price of product can’t return when get data of product in functions.php
- Woocommerce product price change
- is_product_category(‘Services’) not working
- Woocommerce – if selected attribute term equals
- Parent category as WOOCommerce Categories widget title
- Problem with my footer after changing WooCommerce Products Sorting [closed]
- Woocommerce – Switching Price for Category
- Multiple Notifications SetInterval
- Echo a String Based On Geolocation? [Woocommerce || ACF]
- How do i create a search option for pdf’s only
- Move product attributes after summary on single product page
- Show number of sold products but be first for less than 2
- Load scripts into an AJAX div
- Load scripts into an AJAX div
- function syntax is off,
- True parameter but jquery register in header and not in the footer with wp_register_script
- Why are some custom javascript files working but some are not
- WordPress Javascript Widget jQuery Dependency Issue
- Having problems loading Jquery in functions.php
- Get term count on a category page
- Woocommerce – Checkout error message
- add variable to actions/functions across different files (woocommerce)
- AJAX values converted to PHP Variables?
- Animated Accordion [closed]