Shipping Settings: Remove zone method defaults (#40838)

This commit is contained in:
Paul Sealock 2023-10-20 07:17:02 +13:00 committed by paul sealock
parent 1a0da8a62d
commit 6f460e603a
12 changed files with 53 additions and 9 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Comment: Fix already implemented behaviour

View File

@ -148,7 +148,7 @@ if ( ! defined( 'ABSPATH' ) ) {
</article>
<footer>
<div class="inner">
<button id="btn-ok" data-status='{{ data.status }}' class="button button-primary button-large">
<button id="btn-ok" data-status='{{ data.status }}' disabled='{{ data.status === "new" ? "disabled" : "" }}' class="button button-primary button-large {{ data.status === 'new' ? 'disabled' : '' }}">
<div class="wc-backbone-modal-action-{{ data.status === 'new' ? 'active' : 'inactive' }}"><?php esc_html_e( 'Create', 'woocommerce' ); ?></div>
<div class="wc-backbone-modal-action-{{ data.status === 'existing' ? 'active' : 'inactive' }}"><?php esc_html_e( 'Save', 'woocommerce' ); ?></div>
</button>

View File

@ -14,7 +14,8 @@ $settings = array(
'title' => __( 'Name', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Flat rate', 'woocommerce' ),
'default' => '',
'placeholder' => __( 'e.g. Standard national', 'woocommerce' ),
'desc_tip' => true,
),
'tax_status' => array(

View File

@ -92,7 +92,8 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
'title' => __( 'Name', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => $this->method_title,
'default' => '',
'placeholder' => __( 'e.g. Free shipping', 'woocommerce' ),
'desc_tip' => true,
),
'requires' => array(

View File

@ -88,7 +88,8 @@ class WC_Shipping_Local_Pickup extends WC_Shipping_Method {
'title' => __( 'Name', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Local pickup', 'woocommerce' ),
'default' => '',
'placeholder' => __( 'e.g. Local pickup', 'woocommerce' ),
'desc_tip' => true,
),
'tax_status' => array(

View File

@ -86,6 +86,9 @@ test.describe( 'WooCommerce Shipping Settings - Add new shipping zone', () => {
await page.getByRole('button', { name: 'Continue' } ).last().click();
await page.waitForLoadState( 'networkidle' );
await page
.getByPlaceholder( 'e.g. Local pickup' )
.fill( 'Local pickup' );
await page.locator( '#btn-ok' ).click();
await page.waitForLoadState( 'networkidle' );
@ -145,7 +148,10 @@ test.describe( 'WooCommerce Shipping Settings - Add new shipping zone', () => {
await page.getByText( 'Free shipping', { exact: true } ).click();
await page.getByRole('button', { name: 'Continue' } ).last().click();
await page.waitForLoadState( 'networkidle' );
await page
.getByPlaceholder( 'e.g. Free shipping' )
.fill( 'Free shipping' );
await page.locator( '#btn-ok' ).click();
await page.waitForLoadState( 'networkidle' );
@ -202,6 +208,9 @@ test.describe( 'WooCommerce Shipping Settings - Add new shipping zone', () => {
await page.getByRole('button', { name: 'Continue' } ).last().click();
await page.waitForLoadState( 'networkidle' );
await page
.getByPlaceholder( 'e.g. Standard national' )
.fill( 'Flat rate' );
await page.locator( '#btn-ok' ).click();
await page.waitForLoadState( 'networkidle' );
@ -328,6 +337,9 @@ test.describe( 'WooCommerce Shipping Settings - Add new shipping zone', () => {
await page.waitForLoadState( 'networkidle' );
await page
.getByPlaceholder( 'e.g. Standard national' )
.fill( 'Flat rate' );
await page.locator( '#btn-ok' ).click();
await page.waitForLoadState( 'networkidle' );
@ -423,13 +435,20 @@ test.describe( 'Verifies shipping options from customer perspective', () => {
method_id: 'flat_rate',
settings: {
cost: '10.00',
title: 'Flat rate',
},
} );
await api.post( `shipping/zones/${ shippingFreeId }/methods`, {
method_id: 'free_shipping',
settings: {
title: 'Free shipping',
}
} );
await api.post( `shipping/zones/${ shippingLocalId }/methods`, {
method_id: 'local_pickup',
settings: {
title: 'Local pickup',
}
} );
} );

View File

@ -78,15 +78,22 @@ test.describe( 'Cart Calculate Shipping', () => {
// set shipping zone methods
await api.post( `shipping/zones/${ shippingZoneDEId }/methods`, {
method_id: 'free_shipping',
settings: {
title: 'Free shipping',
},
} );
await api.post( `shipping/zones/${ shippingZoneFRId }/methods`, {
method_id: 'flat_rate',
settings: {
title: 'Flat rate',
cost: '5.00',
},
} );
await api.post( `shipping/zones/${ shippingZoneFRId }/methods`, {
method_id: 'local_pickup',
settings: {
title: 'Local pickup',
},
} );
// confirm that we allow shipping to any country
await api.put( 'settings/general/woocommerce_allowed_countries', {

View File

@ -66,6 +66,9 @@ test.describe( 'Shopper Checkout Create Account', () => {
] );
await api.post( `shipping/zones/${ shippingZoneId }/methods`, {
method_id: 'free_shipping',
settings: {
title: 'Free shipping',
}
} );
await api.put( 'payment_gateways/cod', {
enabled: true,

View File

@ -62,6 +62,9 @@ test.describe( 'Shopper Checkout Login Account', () => {
] );
await api.post( `shipping/zones/${ shippingZoneId }/methods`, {
method_id: 'free_shipping',
settings: {
title: 'Free shipping',
}
} );
// create customer and save its id
await api

View File

@ -67,6 +67,9 @@ test.describe( 'Checkout page', () => {
] );
await api.post( `shipping/zones/${ shippingZoneId }/methods`, {
method_id: 'free_shipping',
settings: {
title: 'Free shipping',
}
} );
// enable bank transfers and COD for payment
await api.put( 'payment_gateways/bacs', {

View File

@ -680,7 +680,7 @@ class WC_Tests_API_Shipping_Zones_V2 extends WC_REST_Unit_Test_Case {
$data = $response->get_data();
$this->assertArrayHasKey( 'title', $data['settings'] );
$this->assertEquals( 'Flat rate', $data['settings']['title']['value'] );
$this->assertEquals( '', $data['settings']['title']['value'] );
$this->assertArrayHasKey( 'tax_status', $data['settings'] );
$this->assertEquals( 'taxable', $data['settings']['tax_status']['value'] );
$this->assertArrayHasKey( 'cost', $data['settings'] );
@ -691,7 +691,8 @@ class WC_Tests_API_Shipping_Zones_V2 extends WC_REST_Unit_Test_Case {
$request->set_body_params(
array(
'settings' => array(
'cost' => 5,
'cost' => 5,
'title' => 'Flat rate',
),
)
);

View File

@ -703,7 +703,7 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
$data = $response->get_data();
$this->assertArrayHasKey( 'title', $data['settings'] );
$this->assertEquals( 'Flat rate', $data['settings']['title']['value'] );
$this->assertEquals( '', $data['settings']['title']['value'] );
$this->assertArrayHasKey( 'tax_status', $data['settings'] );
$this->assertEquals( 'taxable', $data['settings']['tax_status']['value'] );
$this->assertArrayHasKey( 'cost', $data['settings'] );
@ -714,7 +714,8 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
$request->set_body_params(
array(
'settings' => array(
'cost' => 5,
'cost' => 5,
'title' => 'Flat rate',
),
)
);