Block-based checkout - Shipping section changes (#46083)

* Refactor shipping sections

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Refactor various files and adjust e2e tests

* Display expected styles for “Ship” and “Pickup” in the page editor

* Use exact selector

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Niels Lange 2024-04-30 19:59:03 +07:00 committed by GitHub
parent 987d702335
commit 1d93ba0b6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 34 additions and 32 deletions

View File

@ -11,7 +11,7 @@ import { defaultShippingText, defaultLocalPickupText } from './constants';
export default {
...formStepAttributes( {
defaultTitle: __( 'Shipping method', 'woocommerce' ),
defaultTitle: __( 'Delivery', 'woocommerce' ),
defaultDescription: __(
'Select how you would like to receive your order.',
'woocommerce'
@ -27,7 +27,7 @@ export default {
},
showPrice: {
type: 'boolean',
default: true,
default: false,
},
localPickupText: {
type: 'string',

View File

@ -1,7 +1,7 @@
{
"name": "woocommerce/checkout-shipping-method-block",
"version": "1.0.0",
"title": "Shipping Method",
"title": "Delivery",
"description": "Select between shipping or local pickup.",
"category": "woocommerce",
"supports": {

View File

@ -3,6 +3,6 @@
*/
import { __ } from '@wordpress/i18n';
export const defaultLocalPickupText = __( 'Local Pickup', 'woocommerce' );
export const defaultLocalPickupText = __( 'Pickup', 'woocommerce' );
export const defaultShippingText = __( 'Shipping', 'woocommerce' );
export const defaultShippingText = __( 'Ship', 'woocommerce' );

View File

@ -263,7 +263,7 @@ export const Edit = ( {
<ExternalLinkCard
key={ 'pickup_location' }
href={ `${ ADMIN_URL }admin.php?page=wc-settings&tab=shipping&section=pickup_location` }
title={ __( 'Local Pickup', 'woocommerce' ) }
title={ __( 'Pickup', 'woocommerce' ) }
description={ __(
'Allow customers to choose a local pickup location during checkout.',
'woocommerce'

View File

@ -9,7 +9,7 @@
.wc-block-checkout__shipping-method-option {
flex-grow: 1;
display: flex;
flex-direction: column;
flex-direction: row;
justify-content: center;
align-items: center;
height: 100%;
@ -17,11 +17,11 @@
flex-basis: 0;
gap: 4px;
padding: 16px 12px;
color: inherit;
color: inherit !important; // Overwriting Gutenberg styles
background-color: transparent;
border: none;
box-shadow: none !important;
outline: 1px solid $universal-border-light;
outline: 1px solid $universal-border-light !important; // Overwriting Gutenberg styles
border-radius: $universal-border-radius;
&.components-button:hover:not(:disabled),
&.components-button:focus:not(:disabled),

View File

@ -103,7 +103,7 @@ const GeneralSettings = () => {
'This is the shipping method title shown to customers.',
'woocommerce'
) }
placeholder={ __( 'Local Pickup', 'woocommerce' ) }
placeholder={ __( 'Pickup', 'woocommerce' ) }
value={ settings.title }
onChange={ setSettingField( 'title' ) }
disabled={ false }

View File

@ -27,7 +27,7 @@ export const indexLocationsById = (
export const defaultSettings = {
enabled: false,
title: __( 'Local Pickup', 'woocommerce' ),
title: __( 'Pickup', 'woocommerce' ),
tax_status: 'taxable',
cost: '',
};

View File

@ -136,7 +136,7 @@ test.describe( 'Shopper → Local pickup', () => {
await frontendUtils.addToCart( SIMPLE_PHYSICAL_PRODUCT_NAME );
await frontendUtils.goToCheckout();
await page.getByRole( 'radio', { name: 'Local Pickup free' } ).click();
await page.getByRole( 'radio', { name: 'Pickup' } ).click();
await expect( page.getByLabel( 'Testing' ).last() ).toBeVisible();
await page.getByLabel( 'Testing' ).last().check();
@ -158,7 +158,9 @@ test.describe( 'Shopper → Local pickup', () => {
await frontendUtils.addToCart( SIMPLE_PHYSICAL_PRODUCT_NAME );
await frontendUtils.goToCheckout();
await page.getByRole( 'radio', { name: 'Local Pickup free' } ).click();
await page
.getByRole( 'radio', { name: 'Pickup', exact: true } )
.click();
await page
.getByLabel( 'Email address' )
.fill( 'thisShouldRemainHere@mail.com' );
@ -166,19 +168,21 @@ test.describe( 'Shopper → Local pickup', () => {
'thisShouldRemainHere@mail.com'
);
await page.getByRole( 'radio', { name: 'Shipping from free' } ).click();
await page.getByRole( 'radio', { name: 'Ship', exact: true } ).click();
await expect( page.getByLabel( 'Email address' ) ).toHaveValue(
'thisShouldRemainHere@mail.com'
);
await checkoutPageObject.fillInCheckoutWithTestData();
await page.getByRole( 'radio', { name: 'Local Pickup free' } ).click();
await page
.getByRole( 'radio', { name: 'Pickup', exact: true } )
.click();
await expect( page.getByLabel( 'Email address' ) ).toHaveValue(
'john.doe@test.com'
);
await page.getByRole( 'radio', { name: 'Shipping from free' } ).click();
await page.getByRole( 'radio', { name: 'Ship', exact: true } ).click();
await expect( page.getByLabel( 'Email address' ) ).toHaveValue(
'john.doe@test.com'
);

View File

@ -179,9 +179,7 @@ test.describe( 'Shopper → Order Confirmation → Local Pickup', () => {
await frontendUtils.goToShop();
await frontendUtils.addToCart( SIMPLE_PHYSICAL_PRODUCT_NAME );
await frontendUtils.goToCheckout();
await pageObject.page
.getByRole( 'radio', { name: 'Local Pickup free' } )
.click();
await pageObject.page.getByRole( 'radio', { name: 'Pickup' } ).click();
await pageObject.fillInCheckoutWithTestData();
await pageObject.placeOrder();
await expect(

View File

@ -44,7 +44,7 @@ test.describe( 'Merchant → Local Pickup Settings', () => {
'woocommerce/checkout-shipping-method-block'
);
await editor.selectBlocks( block );
const fakeInput = editor.canvas.getByLabel( 'Local Pickup' );
const fakeInput = editor.canvas.getByLabel( 'Pickup', { exact: true } );
await fakeInput.click();
const isMacOS = process.platform === 'darwin'; // darwin is macOS

View File

@ -24,23 +24,19 @@ test.describe( 'Merchant → Local Pickup Settings', () => {
} );
test( 'user can change the title', async ( { page, localPickupUtils } ) => {
await page
.getByPlaceholder( 'Local Pickup' )
.fill( 'Local Pickup Test #1' );
await page.getByPlaceholder( 'Pickup' ).fill( 'Local Pickup Test #1' );
await localPickupUtils.saveLocalPickupSettings();
await expect( page.getByPlaceholder( 'Local Pickup' ) ).toHaveValue(
await expect( page.getByPlaceholder( 'Pickup' ) ).toHaveValue(
'Local Pickup Test #1'
);
await page
.getByPlaceholder( 'Local Pickup' )
.fill( 'Local Pickup Test #2' );
await page.getByPlaceholder( 'Pickup' ).fill( 'Local Pickup Test #2' );
await localPickupUtils.saveLocalPickupSettings();
await expect( page.getByPlaceholder( 'Local Pickup' ) ).toHaveValue(
await expect( page.getByPlaceholder( 'Pickup' ) ).toHaveValue(
'Local Pickup Test #2'
);
} );

View File

@ -46,7 +46,7 @@ export const merchant = {
await expect( page ).toFill(
'input[name="local_pickup_title"]',
'Local Pickup'
'Pickup'
);
await merchant.saveLocalPickupSettingsPageWithRefresh();
},

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
Update delivery titles & pickup options; refine shipping selector layout & address field visibility in the Checkout block.

View File

@ -459,7 +459,7 @@ class ShippingController {
$data = array(
'local_pickup_enabled' => 'yes' === $settings['enabled'] ? true : false,
'title' => __( 'Local Pickup', 'woocommerce' ) === $settings['title'],
'title' => __( 'Pickup', 'woocommerce' ) === $settings['title'],
'price' => '' === $settings['cost'] ? true : false,
'cost' => '' === $settings['cost'] ? 0 : $settings['cost'],
'taxes' => $settings['tax_status'],

View File

@ -17,12 +17,12 @@ class LocalPickupUtils {
'woocommerce_pickup_location_settings',
[
'enabled' => 'no',
'title' => __( 'Local Pickup', 'woocommerce' ),
'title' => __( 'Pickup', 'woocommerce' ),
]
);
if ( empty( $pickup_location_settings['title'] ) ) {
$pickup_location_settings['title'] = __( 'Local Pickup', 'woocommerce' );
$pickup_location_settings['title'] = __( 'Pickup', 'woocommerce' );
}
if ( empty( $pickup_location_settings['enabled'] ) ) {