diff --git a/packages/js/data/changelog/add-40348_notice_when_product_has_local_attributes b/packages/js/data/changelog/add-40348_notice_when_product_has_local_attributes new file mode 100644 index 00000000000..9e486f80de7 --- /dev/null +++ b/packages/js/data/changelog/add-40348_notice_when_product_has_local_attributes @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Modify notice for legacy local attributes #41646 diff --git a/packages/js/data/src/user/types.ts b/packages/js/data/src/user/types.ts index d3c40b1200b..97f11e892ac 100644 --- a/packages/js/data/src/user/types.ts +++ b/packages/js/data/src/user/types.ts @@ -28,13 +28,14 @@ export type UserPreferences = { variable_product_tour_shown?: string; variable_product_block_tour_shown?: string; variations_report_columns?: string; - product_block_variable_options_notice_dismissed?: string; + local_attributes_notice_dismissed_ids?: number[]; variable_items_without_price_notice_dismissed?: Record< number, string >; }; export type WoocommerceMeta = UserPreferences & { task_list_tracked_started_tasks?: string; variable_items_without_price_notice_dismissed?: string; + local_attributes_notice_dismissed_ids?: string; }; export type WCUser< diff --git a/packages/js/product-editor/changelog/add-40348_notice_when_product_has_local_attributes b/packages/js/product-editor/changelog/add-40348_notice_when_product_has_local_attributes new file mode 100644 index 00000000000..9e486f80de7 --- /dev/null +++ b/packages/js/product-editor/changelog/add-40348_notice_when_product_has_local_attributes @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Modify notice for legacy local attributes #41646 diff --git a/packages/js/product-editor/src/blocks/product-fields/variation-options/edit.tsx b/packages/js/product-editor/src/blocks/product-fields/variation-options/edit.tsx index 0e7f4bffe27..24b99091e1b 100644 --- a/packages/js/product-editor/src/blocks/product-fields/variation-options/edit.tsx +++ b/packages/js/product-editor/src/blocks/product-fields/variation-options/edit.tsx @@ -16,6 +16,7 @@ import { } from '@woocommerce/data'; import { recordEvent } from '@woocommerce/tracks'; import { Link } from '@woocommerce/components'; +import { getAdminLink } from '@woocommerce/settings'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore No types for this exist yet. // eslint-disable-next-line @woocommerce/dependency-group @@ -31,13 +32,13 @@ import { ProductEditorBlockEditProps } from '../../../types'; export function Edit( { attributes: blockAttributes, + context, }: ProductEditorBlockEditProps< BlockAttributes > ) { const blockProps = useWooBlockProps( blockAttributes ); const { generateProductVariations } = useProductVariationsHelper(); const { updateUserPreferences, - product_block_variable_options_notice_dismissed: - hasDismissedVariableOptionsNotice, + local_attributes_notice_dismissed_ids: dismissedNoticesIds = [], } = useUserPreferences(); const [ entityAttributes, setEntityAttributes ] = useEntityProp< @@ -51,6 +52,9 @@ export function Edit( { 'default_attributes' ); + const { postType } = context; + const productId = useEntityId( 'postType', postType ); + const { attributes, handleChange } = useProductAttributes( { allAttributes: entityAttributes, isVariationAttributes: true, @@ -68,7 +72,7 @@ export function Edit( { let notice: string | React.ReactElement = ''; if ( localAttributeNames.length > 0 && - hasDismissedVariableOptionsNotice !== 'yes' + ! dismissedNoticesIds?.includes( productId ) ) { notice = createInterpolateElement( __( @@ -87,7 +91,9 @@ export function Edit( { ), globalAttributeLink: ( @@ -122,7 +128,10 @@ export function Edit( { useRemoveConfirmationModal={ true } onNoticeDismiss={ () => updateUserPreferences( { - product_block_variable_options_notice_dismissed: 'yes', + local_attributes_notice_dismissed_ids: [ + ...dismissedNoticesIds, + productId, + ], } ) } onAddAnother={ () => { diff --git a/plugins/woocommerce/changelog/add-40348_notice_when_product_has_local_attributes b/plugins/woocommerce/changelog/add-40348_notice_when_product_has_local_attributes new file mode 100644 index 00000000000..9e486f80de7 --- /dev/null +++ b/plugins/woocommerce/changelog/add-40348_notice_when_product_has_local_attributes @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Modify notice for legacy local attributes #41646 diff --git a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php b/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php index df2816d0efe..9e7f892a80e 100644 --- a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php +++ b/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php @@ -175,7 +175,7 @@ class Init { $user_data_fields, array( 'variable_product_block_tour_shown', - 'product_block_variable_options_notice_dismissed', + 'local_attributes_notice_dismissed_ids', 'variable_items_without_price_notice_dismissed', ) );