Title: CheckoutPage
Last modified: August 21, 2021

---

# CheckoutPage

 *  Resolved [mosesclarke91](https://wordpress.org/support/users/mosesclarke91/)
 * (@mosesclarke91)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/checkoutpage-2/)
 * Hello,
 * I am looking for help with two things.
    I ship my product only to Ireland and
   Northern Ireland (which is in the UK). I am looking to have the Eircode (Ireland)
   and Postcode (UK) a mandatory field in my checkout page. Is this possible? Currently
   it says optional beside this field. I am also looking to change the field which
   says ‘company name (optional)’ to ‘Pets name’ and also make this field mandatory.
   Is this possible?
 * Hopefully you understand what I mean and can see it in my linked URL. TIA.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcheckoutpage-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [Ian Sackofwits](https://wordpress.org/support/users/plantprogrammer/)
 * (@plantprogrammer)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/checkoutpage-2/#post-14792611)
 * Hi, mosesclarke91, I’m another WooCommerce user.
 * It is possible to make optional fields mandatory by hooking into WooCommerce 
   hooks that exist.
 * The WooCommerce documentation goes into good detail about how to do this:
    [https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/](https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/)
 * This PHP code (add to your functions.php file or use a plugin like Code Snippets)
   should help you:
 *     ```
       // Hook in
       add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );
   
       // Our hooked in function - $address_fields is passed via the filter!
       function custom_override_default_address_fields( $address_fields ) {
            $address_fields['postcode']['required'] = true;
            $address_fields['company']['required'] = true;
            $address_fields['company']['label'] = __('Pets name');
   
            return $address_fields;
       }
       ```
   
 *  Thread Starter [mosesclarke91](https://wordpress.org/support/users/mosesclarke91/)
 * (@mosesclarke91)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/checkoutpage-2/#post-14793344)
 * Hi,
 * Amazing. Thanks for so much this code. So I can just insert this code into the
   plugin ‘code snippets’ and it will insert this code into the PHP of WooCommerce?
   Then when WooCommerce updates it wont effect this code, that’s how code snippet
   works?
 *  [Mirko P.](https://wordpress.org/support/users/rainfallnixfig/)
 * (@rainfallnixfig)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/checkoutpage-2/#post-14793427)
 * Hi [@mosesclarke91](https://wordpress.org/support/users/mosesclarke91/),
 * > So I can just insert this code into the plugin ‘code snippets’ and it will 
   > insert this code into the PHP of WooCommerce? Then when WooCommerce updates
   > it wont effect this code, that’s how code snippet works?
 * That’s correct! If you’re using Code Snippets, updating WooCommerce will not 
   have any effect on the custom code saved there.
 * Cheers.
 *  Thread Starter [mosesclarke91](https://wordpress.org/support/users/mosesclarke91/)
 * (@mosesclarke91)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/checkoutpage-2/#post-14793542)
 * Hi,
 * Amazing. Thank you. I have read on the code snippets plugin support that some
   sites have completely collapsed after using code snippets.
    Is there anything
   I can do to try avoid this before inserting the snippet?
 * Thanks in advance!!
 *  Thread Starter [mosesclarke91](https://wordpress.org/support/users/mosesclarke91/)
 * (@mosesclarke91)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/checkoutpage-2/#post-14793654)
 * Hi guys,
 * It worked. Thank you so much!!! I was worried about the site crashing but it 
   did not. Thank you [@plantprogrammer](https://wordpress.org/support/users/plantprogrammer/)
   for designing this code for me!!
    The only addition I need to this code is that
   there are 2 shipping options, Ireland and the UK. Postcode is from the UK. But
   in Ireland this is known as the Eircode. Is there a way to add in an extra line
   to make the Eircode also mandatory?
 * Again, thank you so much for your help. I really appreciate it!
 *  Plugin Support [abwaita a11n](https://wordpress.org/support/users/abwaita/)
 * (@abwaita)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/checkoutpage-2/#post-14794278)
 * Hi [@mosesclarke91](https://wordpress.org/support/users/mosesclarke91/),
 * Glad to hear that the code worked well to make fields mandatory.
 * >  I have read on the code snippets plugin support that some sites have completely
   > collapsed after using code snippets. Is there anything I can do to try avoid
   > this before inserting the snippet?
 * You can backup the site before adding the code and use a staging site to first
   test the code. For more info, kindly check [this backup and staging section](https://docs.woocommerce.com/document/how-to-test-for-conflicts/#section-3)
   of one of our documentations .
 * > The only addition I need to this code is that there are 2 shipping options,
   > Ireland and the UK. Postcode is from the UK. But in Ireland this is known as
   > the Eircode. Is there a way to add in an extra line to make the Eircode also
   > mandatory?
 * Hoping that I understood this right, it seems that you want to have a limit on
   the countries to ship. If so, you can do it without custom code.
 * To make the available shipping countries to only be UK and Ireland in **WooCommerce
   → Settings → General → Sell to specific countries**:
 * 
    Link to image: [https://snipboard.io/cfxa76.jpg](https://snipboard.io/cfxa76.jpg)
 * Hope this helps.
    Thanks.
 *  Thread Starter [mosesclarke91](https://wordpress.org/support/users/mosesclarke91/)
 * (@mosesclarke91)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/checkoutpage-2/#post-14794855)
 * Hi [@abwaita](https://wordpress.org/support/users/abwaita/) ,
 * Thanks for this info. Interesting about the staging plug in. I will use this 
   feature in the future.
 * I am already shipping to Ireland and to the UK.
    My query is relating to the 
   above php code for making the postcode mandatory. Postcode is in the UK. But 
   Eircode is in Ireland. So at the moment when somebody buys my product in the 
   UK their postcode is mandatory. But when somebody buys in Ireland the Eircode
   is not yet mandatory. Can I tweak the above code to include EIRCODE as well as
   POSTCODE to be both mandatory depending on which country they are shipping to.
   Hopefully this makes sense.
 * Thanks
 *  [Mirko P.](https://wordpress.org/support/users/rainfallnixfig/)
 * (@rainfallnixfig)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/checkoutpage-2/#post-14796652)
 * Hi [@mosesclarke91](https://wordpress.org/support/users/mosesclarke91/),
 * In this particular forum we’re focused on the default features of WooCommerce
   and, from time to time, you can get help from developers hanging out here willing
   to help.
 * [@plantprogrammer](https://wordpress.org/support/users/plantprogrammer/) could
   possibly help you tweak the code but I would definitely recommend reaching out
   to more development-oriented channels such as these ones:
    - [WooCommerce Slack Community](https://woocommerce.com/community-slack/)
    - [Advanced WooCommerce group on Facebook](https://www.facebook.com/groups/advanced.woocommerce/)
 * Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘CheckoutPage’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 8 replies
 * 4 participants
 * Last reply from: [Mirko P.](https://wordpress.org/support/users/rainfallnixfig/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/checkoutpage-2/#post-14796652)
 * Status: resolved