Support » Plugin: WooCommerce » Cannot Change Postal/ZIP* label text

  • Resolved jennineh

    (@jennineh)


    Hi,

    I’ve been trying to change the label test for postal/Zip checkout field, however it has not been working for me. This is the code I used

    // WooCommerce Checkout Fields Hook
    add_filter( 'woocommerce_checkout_fields' , 'custom_wc_checkout_fields', 'custom_override_checkout_fields', 1 );
    // Change order comments placeholder and label, and set billing phone number to not required.
    function custom_wc_checkout_fields( $fields ) {
        $fields['billing']['billing_postcode']['label'] = 'Enter your label <a href="https://shopbeemo.com/checkout/">here</a>.';
        $fields['billing']['billing_postcode']['required'] = false;
        return $fields;
        
        
    }

    When I do it for other checkout fields it works fine, but specifically not for postcodes

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • The placeholder you can change I but I think it is no longer allowed to change the Zip to something other than that. It’s needed for Shipping plugins. Changing that messes up the aJax. That’s what I believe.

    You may want to try this. Not sure it will work.
    https://wordpress.org/plugins/woocommerce-jetpack/

    Hi, Thank you. It works well actually! :-).

    I have another questions, if you are able to answer. I changed ‘Postal/ZIP’ to ‘Shipping Code’ and I want to make the field a drop-down so that customers can select which Shipping Code they fall under, these are shipping codes that I made up for my Stores shipping because my country does not have any for me to create shipping zones with. this is the code I used to used to make the ‘City’ field into a drop-down:

    add_filter( 'wc_city_select_cities', 'my_cities' );
    /**
     * Replace XX with the country code. Instead of YYY, ZZZ use actual  state codes.
     */
    function my_cities( $cities ) {
        $cities['BZ'] = array(
            'CZ' => array(
                'Corozal Town',
                'Calcutta Village',
                'Ranchito',
            ),
            'CY' => array(
                'San Ignacio',
                'Santa Elena',
                'Benque Viejo',
            ),
            'BEL' => array(
                'Belize City',
                'Ladyville',
                'Sandhill',
                'Hattieville',
            ),
            'TL' => array(
                'Placencia',
                'Independence',
                'Punta Gorda',
            ),
            'OW' => array(
                'Orange Walk Town',
                
            )
        );
        return $cities;
    }

    Do you know how I can make the postal code field a drop-down as well?

    I think anything is possible. Hopefully a plugin happiness agent comes in

    :-). Thank you.

    Hi @jennineh,

    This should do almost everything you need. The only thing it does not do is give you the ability to edit this value after it has been submitted via the admin or order pages.

    Due to the length I am linking it as a gist.

    I also added comments to each section so hopefully it all makes sense. If not, let me know.

    https://gist.github.com/mtruitt/9741f611577f4b76dd36bee316af1dee

    Good Morning,

    I tried your codes and it works! Thank you.

    The only issue is on the ‘Addresses’ section on the customer’s account dashboard. where they can edit their billing and shipping addresses. The default ‘Postal/ZIP*’ is still displayed here, how can I change that so that both fields on the checkout page and in the customer’s account are synced?

    My idea is to use the shipping code as the source to create shipping zones and map the customer’s shipping methods. My country does not have a postal code system, so now i’m trying to create a system that will work efficiently for my store.

    Hello @mtruitt,
    The code indicated in githup, in what part of the woocommerce files do I put it?
    https://gist.github.com/mtruitt/9741f611577f4b76dd36bee316af1dee
    Very Thanks

    mtruitt

    (@mtruitt)

    @mcamposs

    This would go in the functions.php file.

    Plugin Support John Coy

    (@johndcoy)

    Automattic Happiness Engineer

    Hi @mcamposs

    You can also use the Code Snippets plugin to add code independently to another plugin or the active theme:

    https://wordpress.org/plugins/code-snippets/

    It’ll also help to prevent the site from crashing if the code is a failure. 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Cannot Change Postal/ZIP* label text’ is closed to new replies.