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.