Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi there,

    You can use the actions and filters mentioned on the page Customizing checkout fields using actions and filters to make the billing post code optional.

    I have also found a code snippet on this article that can help.

    /** Other billing fields 
    * true = required
    * false = optional
    */
    add_filter( 'woocommerce_default_address_fields', 'customize_extra_fields', 1000, 1 );
    function customize_extra_fields( $address_fields ) {
    $address_fields['postcode']['required'] = false; //Postcode
    return $address_fields;
    }

    Use the code snippet plugin to apply those codes to your site.

    Thread Starter leoce

    (@leoce)

    Hi @pankajkmr
    Both those options relate to Shortcode based Checkout flow, they don’t apply to Blocks Cart and Checkout, or I miss smht?
    Thanks.

    Hi @leoce

    There was a change in February which takes the rules for block checkout address fields from the locale. WooCommerce maintains a list of country locales with the differences in required address fields, often including postal codes and state fields, which commonly differ between countries.

    The Cart and Checkout Blocks now use those definitions to configure the address fields, including whether postcode is optional or not for a given country.

    I notice your site seems to be based in Romania – to make the postcode optional there, you can try this snippet, which applies a filter to the function that generates the country locale list:

    add_filter('woocommerce_get_country_locale', function($locales) {
    	$locales['RO']['postcode']['required'] = false;
    	return $locales;
    });
    

    I hope this helps. Please note that if you need to make postcode optional for other countries as well, you’d need to modify the snippet to make it apply to them.

    Still under development
    I just want to note that it’s important to remember that extensibility and customizations on the Cart and Checkout Blocks are still under development, and represent the bleeding edge, so if you find you can’t customize them correctly for your needs, these blocks may not yet be suitable for your use.

    In particular, extensions that use hooks related to cart and checkout may not function as expected. Extensions that render additional markup in cart or checkout – for example, custom checkout fields – are not supported.

    The page I linked above will be updated as development continues on the blocks, or you can follow development more closely on GitHub.

    • This reply was modified 3 years, 5 months ago by josha8c. Reason: formatting
    Thread Starter leoce

    (@leoce)

    @josha8c Thank you for support, the snippet worked.
    Indeed it’s still too early to adopt the new Checkout flow. Keep up the good work!

    Plugin Support con

    (@conschneider)

    Engineer

    Hi again!

    Thank you for support, the snippet worked.
    Indeed it’s still too early to adopt the new Checkout flow. Keep up the good work!

    Glad that worked ?? – we will keep at it ;).

    All the best.

    Plugin Support Stuart Duff – a11n

    (@stuartduff)

    Automattic Happiness Engineer

    Hey?@leoce,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can reopen it again if you need be.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘POSTCODE make it “optional” on Checkout Block’ is closed to new replies.