Title: Limit adding addresses
Last modified: November 29, 2021

---

# Limit adding addresses

 *  Resolved [shenalorlof](https://wordpress.org/support/users/shenalorlof/)
 * (@shenalorlof)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/limit-adding-addresses/)
 * Dear supporter,
 * Plugin works smoothly. Thank you for this awesome work. just a small question.
   how to limit adding new addresses?
 * thank you

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

 *  Plugin Author [Matt Harrison](https://wordpress.org/support/users/matt-h/)
 * (@matt-h)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/limit-adding-addresses/#post-15130782)
 * Currently it is not possible to do that.
 * If you are looking to implement it then starting at the add_additional_address_button
   function and adding some kind of check for if the button should be shown or not.
 *  [Art Project Group](https://wordpress.org/support/users/artprojectgroup/)
 * (@artprojectgroup)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/limit-adding-addresses/#post-15438657)
 * Add something like this in `add_additional_address_button` function (class-wc-
   address-book.php – line 234):
 *     ```
       		 <?php if ( 'billing' === $type && apply_filters( 'show_billing_address_button', true ) ) : ?>
       		<div class="add-new-address">
       			<a href="<?php echo esc_url( $this->get_address_book_endpoint_url( $name, 'billing' ) ); ?>" class="add button"><?php echo esc_html_e( 'Add New Billing Address', 'woo-address-book' ); ?></a>
       		</div>
       		<?php endif; ?>
   
       		<?php if ( 'shipping' === $type && apply_filters( 'show_shipping_address_button', true ) ) : ?>
       		<div class="add-new-address">
       			<a href="<?php echo esc_url( $this->get_address_book_endpoint_url( $name, 'shipping' ) ); ?>" class="add button"><?php echo esc_html_e( 'Add New Shipping Address', 'woo-address-book' ); ?></a>
       		</div>
       		<?php endif; ?>
       ```
   
 * We can override it with a simple code like this:
    `add_filter( 'show_shipping_address_button','
   __return_false' );`
 * Example to limit to 3 shipping address:
 *     ```
       function show_address_button() {
           $wc_address_book    = WC_Address_Book::get_instance();
           $shipping_address   = $wc_address_book->get_address_book( get_current_user_id(), 'shipping' );
           if ( count( $shipping_address ) >= 3 ) {
               add_filter( 'show_shipping_address_button', '__return_false' );
           }
       }
       add_action( 'woocommerce_account_edit-address_endpoint',  'show_address_button' );
       ```
   
 * Tested and working!
 * Best regards.
    -  This reply was modified 4 years, 3 months ago by [Art Project Group](https://wordpress.org/support/users/artprojectgroup/).
 *  Plugin Author [Matt Harrison](https://wordpress.org/support/users/matt-h/)
 * (@matt-h)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/limit-adding-addresses/#post-15438791)
 * Thanks for this [@artprojectgroup](https://wordpress.org/support/users/artprojectgroup/)
   those filters can be useful for many things with the add buttons.
 * We have added the filters and released 2.1.0
    Instead of the exact names that
   you used, we used the names `wc_address_book_show_billing_address_button` and`
   wc_address_book_show_shipping_address_button` for them.
 *  [Art Project Group](https://wordpress.org/support/users/artprojectgroup/)
 * (@artprojectgroup)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/limit-adding-addresses/#post-15438815)
 * You’re welcome!
 * Best regards.

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

The topic ‘Limit adding addresses’ is closed to new replies.

 * ![](https://ps.w.org/woo-address-book/assets/icon-256x256.png?rev=2950910)
 * [Address Book for WooCommerce](https://wordpress.org/plugins/woo-address-book/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-address-book/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-address-book/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-address-book/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-address-book/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-address-book/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [Art Project Group](https://wordpress.org/support/users/artprojectgroup/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/limit-adding-addresses/#post-15438815)
 * Status: resolved