From b4efa72b07cd3ad1947b550215104d60569e4fc5 Mon Sep 17 00:00:00 2001 From: Seghir Nadir Date: Mon, 3 Jun 2024 09:11:02 +0200 Subject: [PATCH] Revert "Add phone number to my account shipping address. (#47062)" (#48077) * Revert "Add phone number to my account shipping address. (#47062)" This reverts commit 4840af874a4c59685d874c1e7f3e117e029ec1a8. * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions --- ...evert-shipping-phone-in-shortcode-checkout | 4 +++ .../includes/class-wc-countries.php | 35 ++++++++----------- .../cart-checkout-calculate-tax.spec.js | 2 +- .../e2e-pw/tests/shopper/checkout.spec.js | 4 +-- .../shopper/my-account-addresses.spec.js | 1 - 5 files changed, 20 insertions(+), 26 deletions(-) create mode 100644 plugins/woocommerce/changelog/48077-revert-shipping-phone-in-shortcode-checkout diff --git a/plugins/woocommerce/changelog/48077-revert-shipping-phone-in-shortcode-checkout b/plugins/woocommerce/changelog/48077-revert-shipping-phone-in-shortcode-checkout new file mode 100644 index 00000000000..e65258f8afe --- /dev/null +++ b/plugins/woocommerce/changelog/48077-revert-shipping-phone-in-shortcode-checkout @@ -0,0 +1,4 @@ +Significance: patch +Type: tweak +Comment: This reverts an existing PR. + diff --git a/plugins/woocommerce/includes/class-wc-countries.php b/plugins/woocommerce/includes/class-wc-countries.php index cd04567b85c..8b48da4acbe 100644 --- a/plugins/woocommerce/includes/class-wc-countries.php +++ b/plugins/woocommerce/includes/class-wc-countries.php @@ -1694,15 +1694,12 @@ class WC_Countries { $address_fields[ $type . $key ] = $value; } - // Add fields to address forms. - if ( in_array( $type, array( 'billing_', 'shipping_' ), true ) ) { - // Add phone to billing/shipping address form. - $show_phone_field = get_option( 'woocommerce_checkout_phone_field', 'required' ); - - if ( 'hidden' !== $show_phone_field ) { - $address_fields[ $type . 'phone' ] = array( + // Add email and phone fields. + if ( 'billing_' === $type ) { + if ( 'hidden' !== get_option( 'woocommerce_checkout_phone_field', 'required' ) ) { + $address_fields['billing_phone'] = array( 'label' => __( 'Phone', 'woocommerce' ), - 'required' => 'required' === $show_phone_field, + 'required' => 'required' === get_option( 'woocommerce_checkout_phone_field', 'required' ), 'type' => 'tel', 'class' => array( 'form-row-wide' ), 'validate' => array( 'phone' ), @@ -1710,19 +1707,15 @@ class WC_Countries { 'priority' => 100, ); } - - // Add email to billing address form. - if ( 'billing_' === $type ) { - $address_fields['billing_email'] = array( - 'label' => __( 'Email address', 'woocommerce' ), - 'required' => true, - 'type' => 'email', - 'class' => array( 'form-row-wide' ), - 'validate' => array( 'email' ), - 'autocomplete' => 'no' === get_option( 'woocommerce_registration_generate_username' ) ? 'email' : 'email username', - 'priority' => 110, - ); - } + $address_fields['billing_email'] = array( + 'label' => __( 'Email address', 'woocommerce' ), + 'required' => true, + 'type' => 'email', + 'class' => array( 'form-row-wide' ), + 'validate' => array( 'email' ), + 'autocomplete' => 'no' === get_option( 'woocommerce_registration_generate_username' ) ? 'email' : 'email username', + 'priority' => 110, + ); } /** diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-calculate-tax.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-calculate-tax.spec.js index c9a8d6aec26..01678b1de0e 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-calculate-tax.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-calculate-tax.spec.js @@ -960,7 +960,7 @@ test.describe.serial( 'Tax rates in the cart and checkout', () => { .getByRole( 'textbox', { name: 'ZIP Code *' } ) .type( customer.billing.us.zip ); await page - .getByRole( 'textbox', { name: 'Phone *' } ) + .getByLabel( 'Phone *' ) .fill( customer.billing.us.phone ); await page .getByLabel( 'Email address *' ) diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout.spec.js index 133f845b200..c08a622b731 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout.spec.js @@ -333,9 +333,7 @@ test.describe( 'Checkout page', () => { await page .getByRole( 'textbox', { name: 'ZIP Code *' } ) .fill( '97403' ); - await page - .getByRole( 'textbox', { name: 'Phone *' } ) - .fill( '555 555-5555' ); + await page.getByLabel( 'Phone *' ).fill( '555 555-5555' ); await page.getByLabel( 'Email address *' ).fill( guestEmail ); await page.getByText( 'Cash on delivery' ).click(); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-addresses.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-addresses.spec.js index 6b43d827ce0..37b6d0ea267 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-addresses.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-addresses.spec.js @@ -108,7 +108,6 @@ test.describe( 'Customer can manage addresses in My Account > Addresses page', ( await page.locator( '#shipping_country' ).selectOption( 'US' ); await page.locator( '#shipping_state' ).selectOption( 'NY' ); await page.locator( '#shipping_postcode' ).fill( '10010' ); - await page.locator( '#shipping_phone' ).fill( '555 555-5555' ); await page.locator( 'text=Save address' ).click(); // verify shipping address has been applied