Remove 'List price' and 'Sale price' fields from the General tab (#45495)
* Remove 'List price' and 'Sale price' fields from the General tab * Add changelog file * Fix e2e tests
This commit is contained in:
parent
d8c23c4e3a
commit
979a3c7b62
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: enhancement
|
||||||
|
|
||||||
|
Remove 'List price' and 'Sale price' fields from the General tab
|
|
@ -234,72 +234,6 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// This is needed until hide conditions can be applied to core blocks.
|
|
||||||
$pricing_conditional_wrapper = $basic_details->add_block(
|
|
||||||
array(
|
|
||||||
'id' => 'product-pricing-conditional-wrapper',
|
|
||||||
'blockName' => 'woocommerce/conditional',
|
|
||||||
'order' => 30,
|
|
||||||
'hideConditions' => array(
|
|
||||||
array(
|
|
||||||
'expression' => 'editedProduct.type === "grouped"',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$pricing_wrapper = Features::is_enabled( 'product-grouped' ) ? $pricing_conditional_wrapper : $basic_details;
|
|
||||||
$pricing_columns = $pricing_wrapper->add_block(
|
|
||||||
array(
|
|
||||||
'id' => 'product-pricing-columns',
|
|
||||||
'blockName' => 'core/columns',
|
|
||||||
'order' => 30,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$pricing_column_1 = $pricing_columns->add_block(
|
|
||||||
array(
|
|
||||||
'id' => 'product-pricing-column-1',
|
|
||||||
'blockName' => 'core/column',
|
|
||||||
'order' => 10,
|
|
||||||
'attributes' => array(
|
|
||||||
'templateLock' => 'all',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$pricing_column_1->add_block(
|
|
||||||
array(
|
|
||||||
'id' => 'product-regular-price',
|
|
||||||
'blockName' => 'woocommerce/product-regular-price-field',
|
|
||||||
'order' => 10,
|
|
||||||
'attributes' => array(
|
|
||||||
'name' => 'regular_price',
|
|
||||||
'label' => __( 'List price', 'woocommerce' ),
|
|
||||||
/* translators: PricingTab: This is a link tag to the pricing tab. */
|
|
||||||
'help' => __( 'Manage more settings in <PricingTab>Pricing.</PricingTab>', 'woocommerce' ),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$pricing_column_2 = $pricing_columns->add_block(
|
|
||||||
array(
|
|
||||||
'id' => 'product-pricing-column-2',
|
|
||||||
'blockName' => 'core/column',
|
|
||||||
'order' => 20,
|
|
||||||
'attributes' => array(
|
|
||||||
'templateLock' => 'all',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$pricing_column_2->add_block(
|
|
||||||
array(
|
|
||||||
'id' => 'product-sale-price',
|
|
||||||
'blockName' => 'woocommerce/product-sale-price-field',
|
|
||||||
'order' => 10,
|
|
||||||
'attributes' => array(
|
|
||||||
'label' => __( 'Sale price', 'woocommerce' ),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Description section.
|
// Description section.
|
||||||
$description_section = $general_group->add_section(
|
$description_section = $general_group->add_section(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -50,18 +50,22 @@ test.describe( 'General tab', () => {
|
||||||
)
|
)
|
||||||
.last()
|
.last()
|
||||||
.fill( productData.summary );
|
.fill( productData.summary );
|
||||||
await page
|
|
||||||
.locator(
|
await clickOnTab( 'Pricing', page );
|
||||||
'[id^="wp-block-woocommerce-product-regular-price-field"]'
|
|
||||||
)
|
const regularPrice = page
|
||||||
.first()
|
.locator( 'input[name="regular_price"]' )
|
||||||
.fill( productData.productPrice );
|
.first();
|
||||||
await page
|
await regularPrice.waitFor( { state: 'visible' } );
|
||||||
.locator(
|
await regularPrice.click();
|
||||||
'[id^="wp-block-woocommerce-product-sale-price-field"]'
|
await regularPrice.fill( productData.productPrice );
|
||||||
)
|
|
||||||
.first()
|
const salePrice = page
|
||||||
.fill( productData.salePrice );
|
.locator( 'input[name="sale_price"]' )
|
||||||
|
.first();
|
||||||
|
await salePrice.waitFor( { state: 'visible' } );
|
||||||
|
await salePrice.click();
|
||||||
|
await salePrice.fill( productData.salePrice );
|
||||||
|
|
||||||
await page
|
await page
|
||||||
.locator( '.woocommerce-product-header__actions' )
|
.locator( '.woocommerce-product-header__actions' )
|
||||||
|
@ -86,6 +90,7 @@ test.describe( 'General tab', () => {
|
||||||
await expect( productId ).toBeDefined();
|
await expect( productId ).toBeDefined();
|
||||||
await expect( title ).toHaveText( productData.name );
|
await expect( title ).toHaveText( productData.name );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'can not create a product with duplicated SKU', async ( {
|
test( 'can not create a product with duplicated SKU', async ( {
|
||||||
page,
|
page,
|
||||||
} ) => {
|
} ) => {
|
||||||
|
@ -99,6 +104,8 @@ test.describe( 'General tab', () => {
|
||||||
'[data-template-block-id="basic-details"] .components-summary-control'
|
'[data-template-block-id="basic-details"] .components-summary-control'
|
||||||
)
|
)
|
||||||
.fill( productData.summary );
|
.fill( productData.summary );
|
||||||
|
|
||||||
|
await clickOnTab( 'Pricing', page );
|
||||||
await page
|
await page
|
||||||
.locator(
|
.locator(
|
||||||
'[id^="wp-block-woocommerce-product-regular-price-field"]'
|
'[id^="wp-block-woocommerce-product-regular-price-field"]'
|
||||||
|
@ -117,6 +124,7 @@ test.describe( 'General tab', () => {
|
||||||
|
|
||||||
await expect( textContent ).toMatch( /Invalid or duplicated SKU./ );
|
await expect( textContent ).toMatch( /Invalid or duplicated SKU./ );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'can a shopper add the simple product to the cart', async ( {
|
test( 'can a shopper add the simple product to the cart', async ( {
|
||||||
page,
|
page,
|
||||||
} ) => {
|
} ) => {
|
||||||
|
|
|
@ -37,8 +37,6 @@ test( 'can update the general information of a product', async ( {
|
||||||
name: `Product ${ Date.now() }`,
|
name: `Product ${ Date.now() }`,
|
||||||
description: `Updated description for the awesome product ${ Date.now() }`,
|
description: `Updated description for the awesome product ${ Date.now() }`,
|
||||||
short_description: `Updated summary for the awesome product ${ Date.now() }`,
|
short_description: `Updated summary for the awesome product ${ Date.now() }`,
|
||||||
regularPrice: '100.05',
|
|
||||||
salePrice: '99.05',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const nameTextbox = page.getByLabel( 'Name' ).getByRole( 'textbox' );
|
const nameTextbox = page.getByLabel( 'Name' ).getByRole( 'textbox' );
|
||||||
|
@ -48,22 +46,11 @@ test( 'can update the general information of a product', async ( {
|
||||||
const descriptionTextbox = page
|
const descriptionTextbox = page
|
||||||
.getByLabel( 'Block: Product description' )
|
.getByLabel( 'Block: Product description' )
|
||||||
.getByRole( 'textbox' );
|
.getByRole( 'textbox' );
|
||||||
const listPriceTextbox = page.getByRole( 'textbox', {
|
|
||||||
name: 'List price',
|
|
||||||
} );
|
|
||||||
const salePriceTextbox = page.getByRole( 'textbox', {
|
|
||||||
name: 'Sale price',
|
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( 'edit the product name', async () => {
|
await test.step( 'edit the product name', async () => {
|
||||||
await nameTextbox.fill( updatedProduct.name );
|
await nameTextbox.fill( updatedProduct.name );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
await test.step( 'edit the product price', async () => {
|
|
||||||
await listPriceTextbox.fill( updatedProduct.regularPrice );
|
|
||||||
await salePriceTextbox.fill( updatedProduct.salePrice );
|
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( 'edit the product description and summary', async () => {
|
await test.step( 'edit the product description and summary', async () => {
|
||||||
// Need to clear the textbox before filling it, otherwise the text will be appended.
|
// Need to clear the textbox before filling it, otherwise the text will be appended.
|
||||||
await descriptionTextbox.clear();
|
await descriptionTextbox.clear();
|
||||||
|
@ -91,12 +78,5 @@ test( 'can update the general information of a product', async ( {
|
||||||
await expect
|
await expect
|
||||||
.soft( descriptionTextbox )
|
.soft( descriptionTextbox )
|
||||||
.toHaveText( updatedProduct.description );
|
.toHaveText( updatedProduct.description );
|
||||||
|
|
||||||
await expect
|
|
||||||
.soft( listPriceTextbox )
|
|
||||||
.toHaveValue( updatedProduct.regularPrice );
|
|
||||||
await expect
|
|
||||||
.soft( salePriceTextbox )
|
|
||||||
.toHaveValue( updatedProduct.salePrice );
|
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in New Issue