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:
Maikel David Pérez Gómez 2023-04-24 13:42:45 -04:00 committed by GitHub
parent 2ab11a7236
commit fb7e68a83d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -14,6 +14,10 @@
},
"property": {
"type": "string"
},
"disabled": {
"type": "boolean",
"default": false
}
},
"supports": {

View File

@ -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>

View File

@ -6,4 +6,5 @@ import { BlockAttributes } from '@wordpress/blocks';
export interface ToggleBlockAttributes extends BlockAttributes {
label: string;
property: string;
disabled?: boolean;
}

View File

@ -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

View File

@ -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(