Track stock quantity for this product should be disabled when Enable stock management within settings is disabled, and enabled otherwise (#37957)
* Track stock quantity for this product should be disabled when Enable stock management within settings is disabled, and enabled otherwise. * Add changelog files
This commit is contained in:
parent
2ab11a7236
commit
fb7e68a83d
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Track stock quantity for this product should be disabled when Enable stock management within settings is disabled, and enabled otherwise
|
|
@ -14,6 +14,10 @@
|
|||
},
|
||||
"property": {
|
||||
"type": "string"
|
||||
},
|
||||
"disabled": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
|
|
|
@ -16,7 +16,7 @@ export function Edit( {
|
|||
attributes,
|
||||
}: BlockEditProps< ToggleBlockAttributes > ) {
|
||||
const blockProps = useBlockProps();
|
||||
const { label, property } = attributes;
|
||||
const { label, property, disabled } = attributes;
|
||||
const [ value, setValue ] = useEntityProp< boolean >(
|
||||
'postType',
|
||||
'product',
|
||||
|
@ -28,6 +28,7 @@ export function Edit( {
|
|||
<ToggleControl
|
||||
label={ label }
|
||||
checked={ value }
|
||||
disabled={ disabled }
|
||||
onChange={ setValue }
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -6,4 +6,5 @@ import { BlockAttributes } from '@wordpress/blocks';
|
|||
export interface ToggleBlockAttributes extends BlockAttributes {
|
||||
label: string;
|
||||
property: string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Track stock quantity for this product should be disabled when Enable stock management within settings is disabled, and enabled otherwise
|
|
@ -625,6 +625,7 @@ class WC_Post_Types {
|
|||
array(
|
||||
'label' => __( 'Track stock quantity for this product', 'woocommerce' ),
|
||||
'property' => 'manage_stock',
|
||||
'disabled' => 'yes' !== get_option( 'woocommerce_manage_stock' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
|
|
Loading…
Reference in New Issue