Add a notice to "track inventory" toggle (#40011)
* Add notice to "track inventory" toggle * Add changelogs * Remove console.logs * Fix link URL
This commit is contained in:
parent
bbe053e16e
commit
ccb72125e0
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Add notice to "track inventory" toggle #40011
|
|
@ -19,3 +19,4 @@
|
||||||
@import 'variation-items/editor.scss';
|
@import 'variation-items/editor.scss';
|
||||||
@import 'variation-options/editor.scss';
|
@import 'variation-options/editor.scss';
|
||||||
@import 'taxonomy/editor.scss';
|
@import 'taxonomy/editor.scss';
|
||||||
|
@import 'toggle/editor.scss';
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
"disabled": {
|
"disabled": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"disabledCopy": {
|
||||||
|
"type": "string",
|
||||||
|
"__experimentalRole": "content"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"supports": {
|
"supports": {
|
||||||
|
|
|
@ -11,12 +11,13 @@ import { ToggleControl } from '@wordpress/components';
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
import { ToggleBlockAttributes } from './types';
|
import { ToggleBlockAttributes } from './types';
|
||||||
|
import { sanitizeHTML } from '../../utils/sanitize-html';
|
||||||
|
|
||||||
export function Edit( {
|
export function Edit( {
|
||||||
attributes,
|
attributes,
|
||||||
}: BlockEditProps< ToggleBlockAttributes > ) {
|
}: BlockEditProps< ToggleBlockAttributes > ) {
|
||||||
const blockProps = useBlockProps();
|
const blockProps = useBlockProps();
|
||||||
const { label, property, disabled } = attributes;
|
const { label, property, disabled, disabledCopy } = attributes;
|
||||||
const [ value, setValue ] = useEntityProp< boolean >(
|
const [ value, setValue ] = useEntityProp< boolean >(
|
||||||
'postType',
|
'postType',
|
||||||
'product',
|
'product',
|
||||||
|
@ -31,6 +32,12 @@ export function Edit( {
|
||||||
disabled={ disabled }
|
disabled={ disabled }
|
||||||
onChange={ setValue }
|
onChange={ setValue }
|
||||||
/>
|
/>
|
||||||
|
{ disabled && (
|
||||||
|
<p
|
||||||
|
className="wp-block-woocommerce-product-toggle__disable-copy"
|
||||||
|
dangerouslySetInnerHTML={ sanitizeHTML( disabledCopy ) }
|
||||||
|
/>
|
||||||
|
) }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
.wp-block-woocommerce-product-toggle__disable-copy {
|
||||||
|
margin: $gap-small 0 0;
|
||||||
|
font-size: 12px;
|
||||||
|
color: $gray-700;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Add notice to "track inventory" toggle #40011
|
|
@ -552,6 +552,12 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ
|
||||||
'label' => __( 'Track stock quantity for this product', 'woocommerce' ),
|
'label' => __( 'Track stock quantity for this product', 'woocommerce' ),
|
||||||
'property' => 'manage_stock',
|
'property' => 'manage_stock',
|
||||||
'disabled' => 'yes' !== get_option( 'woocommerce_manage_stock' ),
|
'disabled' => 'yes' !== get_option( 'woocommerce_manage_stock' ),
|
||||||
|
'disabledCopy' => sprintf(
|
||||||
|
/* translators: %1$s: Learn more link opening tag. %2$s: Learn more link closing tag.*/
|
||||||
|
__( 'Per your %1$sstore settings%2$s, inventory management is <strong>disabled</strong>.', 'woocommerce' ),
|
||||||
|
'<a href="' . admin_url( 'admin.php?page=wc-settings&tab=products§ion=inventory' ) . '" target="_blank" rel="noreferrer">',
|
||||||
|
'</a>'
|
||||||
|
),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue