Remove list/sale price from the General tab in grouped products (#42909)

* List and sale price should not be visible in the general tab for grouped products.

* Add changelog files

* Fix lint error
This commit is contained in:
Maikel David Pérez Gómez 2023-12-18 17:26:38 -03:00 committed by GitHub
parent 89fe33d64f
commit 1c3843e4ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 11 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Set passed props to the inner div in DisplayState component

View File

@ -1,7 +1,7 @@
/** /**
* External dependencies * External dependencies
*/ */
import { createElement, Fragment } from '@wordpress/element'; import { createElement } from '@wordpress/element';
/** /**
* Internal dependencies * Internal dependencies
@ -15,13 +15,18 @@ export type DisplayStateProps = {
export const DisplayState: React.FC< DisplayStateProps > = ( { export const DisplayState: React.FC< DisplayStateProps > = ( {
state = 'visible', state = 'visible',
children, children,
...props
} ) => { } ) => {
if ( state === 'visible' ) { if ( state === 'visible' ) {
return <>{ children }</>; return <div { ...props }>{ children }</div>;
} }
if ( state === 'visually-hidden' ) { if ( state === 'visually-hidden' ) {
return <div style={ { display: 'none' } }>{ children }</div>; return (
<div { ...props } style={ { display: 'none' } }>
{ children }
</div>
);
} }
return null; return null;

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Use DisplayState as a direct wrapper of the woocommerce/conditional block

View File

@ -57,12 +57,11 @@ export function Edit( {
); );
return ( return (
<div { ...blockProps }>
<DisplayState <DisplayState
{ ...blockProps }
state={ displayBlocks ? 'visible' : 'visually-hidden' } state={ displayBlocks ? 'visible' : 'visually-hidden' }
> >
<InnerBlocks templateLock="all" /> <InnerBlocks templateLock="all" />
</DisplayState> </DisplayState>
</div>
); );
} }

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Remove list/sale price from the General tab in grouped products

View File

@ -200,7 +200,23 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ
), ),
) )
); );
$pricing_columns = $basic_details->add_block(
// 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( array(
'id' => 'product-pricing-columns', 'id' => 'product-pricing-columns',
'blockName' => 'core/columns', 'blockName' => 'core/columns',