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 display custom field in woocommerce orders in admin panel?
- 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]
- AJAX handler throws 400 (Bad request) – why?
- ajax live search for post title
- 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
- How to save Uploaded image in custom option panel?
- How to Acheive the custom woocommerce category template
- Remove product description from product archive page
- Hide some items from Screen options in dashboard for products
- 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]
- Issue adding text after short description on product pages Woocommerce [closed]
- Display a function using AJAX
- Enqueuing Script in functions.php vs on the page
- Exclude Empty Child Categories in Menu
- Can you use admin pages functionality on the frontend of your site
- Unable to get_the_content(); of a post in WordPress via AJAX
- change billing and shipping address 1 and 2 field placeholders [closed]
- Add external js file to footer with id
- Creating loop within functions.php
- Ajaxing function in widget class
- 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?
- jquery won’t load in footer
- WordPress doesn’t Load JQuery Now? Do I need to enqueue JQuery also?
- WordPress function for 1 to for many
- Pass parameters to function through an action
- change in form-checkout.php by using code in functions.php
- Set quantity of woocommerce product on page visit [closed]
- Replace menu links with # and add name to its li
- Product Tags in Add New product as checkbox list [closed]
- WooCommerce – Reset quantity input field when variation changes
- Calling a function from anywhere, used in different places
- Selective Product Category for Carousel
- Loading CDN that requires jQuery in WordPress
- I want to get product attirbute in the section below
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- Right way to update widget on dynamic new input field
- How to load jQuery in the footer – nothing works for me
- Not sure if enqueuing js scripts properly
- How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]
- Wp_query function to search from product_title ‘OR’ product tags name
- Allow Post Author to be 0 on Update
- Load Woocommerce and WordPress Functions Outside
- Trouble with adding a wp_enqueue_script on wordpress
- WP Ajax Function Always Returning undefined
- How to display custom option field in woocommerce orders in admin panel?
- Scripts not appending to element in AJAX call – why?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- 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
- When sale price is 0.00 show only regular price
- Remove the product category module block from the Woocommerce product page
- How can I get the values of my WordPress $wpdb query in Jquery?
- how can I edit flexslider in woocommerce. [Urgent]
- How to change the order of Jquery in the footer of my theme?
- How to search using ajax for exact phrase or words in an input field?
- how to en-queue jQuery to load before the tag
- Jquery implementation not working on page reload
- woocommerce change currency per category [closed]
- I can’t enqueue my scripts – They literally aren’t being added to my site
- Attempt to change jQuery version caused White Screen of Death
- PHP mixed with some JS code to update WordPress theme settings
- Load jquery only for certain pages in the backend
- Change CSS for logged in users
- Always the Latest google jQuery instead of default WordPress jQuery
- Add a jQuery Function
- jQuery does not work
- using jQuery on only one page
- help I changed one currency in woocommerce and everything is ruined [closed]
- Functions when woocommerce isn’t installed
- 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
- Enqueuing latest version of jQuery into a child theme returns a blank screen
- (Woocommerce) Order by price when entering specific category
- echo custom fields with AJAX
- 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?
- Create custom function for hero image