Skip to content
Fluid Checkout
  • Demo
  • Features
  • Add-ons
    • Complete Bundle Save 42%
    • Fluid Checkout PRO
    • Google Address Autocomplete
    • Address Book
    • EU-VAT Assistant
  • Pricing PRO
  • Docs
  • Support
  • My account
0,00 € 0 items
Home / Docs / fc_pro_address_book_entries_before_add_entry

How can we help?

Customizations

  • Safely add code snippets to your WooCommerce website

Compatibility

  • Troubleshooting – jQuery events or vanilla JavaScript events not working

Troubleshooting

  • Troubleshooting – jQuery events or vanilla JavaScript events not working
  • Troubleshooting – Redirected to error 404 (page not found) when trying to delete an address from the Address Book

Development

  • Filter and action hooks – Address Book
  • Troubleshooting – jQuery events or vanilla JavaScript events not working
  • Changelog – Fluid Checkout Address Book
  • Changelog format and semantic version numbers
View Categories

fc_pro_address_book_entries_before_add_entry

Back to list of all filter and action hooks for Address Book for WooCommerce.

Description #

Modify the address book entries list before adding the new entry to it.

Triggered before the individual new entry is added to the list, and before saving the addresses collection to the database.

Parameters #

  • $address_book_entries (array) All address book entries.
    • address_id (array) Address entry data. for each ID
  • $address_entry (array) New address entry.
    • first_name (string) First name.
    • last_name (string) Last name.
    • address_1 (string) Address line 1.
    • address_2 (string) Address line 2.
    • city (string) City.
    • state (string) State/Province.
    • postcode (string) Postal code.
    • country (string) Country code.
    • company (string) Company name.
    • phone (string) Phone number.
    • email (string) Email address.
  • $user_id (int) User ID.

Examples #

/**
 * Maybe clear default address flags from all existing address book entries.
 *
 * @param   array  $address_book_entries  Existing address book entries.
 * @param   array  $address_entry         Address book being saved.
 * @param   int    $user_id               The user id.
 */
public function maybe_clear_default_address_flags_from_all_addresses( $address_book_entries, $address_entry, $user_id ) {
	// Bail if updating address entry does not have default address flags
	if ( ! is_array( $address_entry ) || ( ! array_key_exists( 'default_shipping', $address_entry ) && ! array_key_exists( 'default_billing', $address_entry ) ) ) { return $address_book_entries; }

	// Maybe clear default shipping flags on all existing addresses
	if ( array_key_exists( 'default_shipping', $address_entry ) && 1 == $address_entry[ 'default_shipping' ] ) {
		// Check if country is allowed for shipping
		if ( FluidCheckout_Steps::instance()->is_country_allowed_for_shipping( $address_entry[ 'country' ] ) ) {
			foreach ( $address_book_entries as $key => $address_book_entry ) {
				$address_book_entries[ $key ][ 'default_shipping' ] = 0;
			}
		}
	}

	// Maybe clear default billing flags on all existing addresses
	if ( array_key_exists( 'default_billing', $address_entry ) && 1 == $address_entry[ 'default_billing' ] ) {
		// Check if country is allowed for billing
		if ( FluidCheckout_Steps::instance()->is_country_allowed_for_billing( $address_entry[ 'country' ] ) ) {
			foreach ( $address_book_entries as $key => $address_book_entry ) {
				$address_book_entries[ $key ][ 'default_billing' ] = 0;
			}
		}
	}

	return $address_book_entries;
}
add_filter( 'fc_pro_address_book_entries_before_add_entry', array( $this, 'maybe_clear_default_address_flags_from_all_addresses' ), 10, 3 );
Still stuck? How can we help?

How can we help?

Updated on December 15, 2025
fc_pro_address_book_entry_before_addfc_pro_address_book_entries_start_tag_markup
Table of Contents
  • Description
  • Parameters
  • Examples
Fluid Checkout

Frictionless Multi-step Checkout for WooCommerce

© 2021-2025 Fluid Checkout OÜ

Terms | Refunds | Privacy Policy | Cookies

Products
  • All products
  • Fluid Checkout PRO
  • Fluid Checkout Lite
  • Google Address Autocomplete add-on
  • Address Book add-on
  • EU-VAT Assistant add-on
Company
  • Support
  • Careers Hiring
  • My account
  • About
  • Homepage
  • Homepage
  • Features
  • Pricing PRO
  • Demo
  • Docs
  • Support
  • My account