diff --git a/packages/js/data/changelog/update-product-editor-dismiss-linked-product-empty-advices b/packages/js/data/changelog/update-product-editor-dismiss-linked-product-empty-advices
new file mode 100644
index 00000000000..1cca075c8ab
--- /dev/null
+++ b/packages/js/data/changelog/update-product-editor-dismiss-linked-product-empty-advices
@@ -0,0 +1,4 @@
+Significance: patch
+Type: update
+
+[Product Block Editor]: dismiss AdviceCard by clicking close button
diff --git a/packages/js/data/src/user/types.ts b/packages/js/data/src/user/types.ts
index 97f11e892ac..91b057b7eff 100644
--- a/packages/js/data/src/user/types.ts
+++ b/packages/js/data/src/user/types.ts
@@ -30,12 +30,16 @@ export type UserPreferences = {
variations_report_columns?: string;
local_attributes_notice_dismissed_ids?: number[];
variable_items_without_price_notice_dismissed?: Record< number, string >;
+ product_advice_card_dismissed?: {
+ [ key: string ]: 'yes' | 'no';
+ };
};
export type WoocommerceMeta = UserPreferences & {
task_list_tracked_started_tasks?: string;
variable_items_without_price_notice_dismissed?: string;
local_attributes_notice_dismissed_ids?: string;
+ product_advice_card_dismissed?: string;
};
export type WCUser<
diff --git a/packages/js/product-editor/changelog/update-product-editor-dismiss-linked-product-empty-advices b/packages/js/product-editor/changelog/update-product-editor-dismiss-linked-product-empty-advices
new file mode 100644
index 00000000000..1cca075c8ab
--- /dev/null
+++ b/packages/js/product-editor/changelog/update-product-editor-dismiss-linked-product-empty-advices
@@ -0,0 +1,4 @@
+Significance: patch
+Type: update
+
+[Product Block Editor]: dismiss AdviceCard by clicking close button
diff --git a/packages/js/product-editor/src/blocks/product-fields/cross-sells/edit.tsx b/packages/js/product-editor/src/blocks/product-fields/cross-sells/edit.tsx
index dfd5d2e675a..104b5823f3c 100644
--- a/packages/js/product-editor/src/blocks/product-fields/cross-sells/edit.tsx
+++ b/packages/js/product-editor/src/blocks/product-fields/cross-sells/edit.tsx
@@ -28,7 +28,6 @@ export function CrossSellsBlockEdit( {
'woocommerce'
) }
image={ }
- isDismissible={ true }
/>
);
diff --git a/packages/js/product-editor/src/blocks/product-fields/upsells/edit.tsx b/packages/js/product-editor/src/blocks/product-fields/upsells/edit.tsx
index b5d99d9c4dd..625bfe9e193 100644
--- a/packages/js/product-editor/src/blocks/product-fields/upsells/edit.tsx
+++ b/packages/js/product-editor/src/blocks/product-fields/upsells/edit.tsx
@@ -26,7 +26,6 @@ export function UpsellsBlockEdit( { attributes }: UpsellsBlockEditComponent ) {
'woocommerce'
) }
image={ }
- isDismissible={ true }
/>
);
diff --git a/packages/js/product-editor/src/components/advice-card/index.tsx b/packages/js/product-editor/src/components/advice-card/index.tsx
index b15257179a1..001bad89be2 100644
--- a/packages/js/product-editor/src/components/advice-card/index.tsx
+++ b/packages/js/product-editor/src/components/advice-card/index.tsx
@@ -11,6 +11,8 @@ import {
CardHeader,
} from '@wordpress/components';
import { close } from '@wordpress/icons';
+import { useInstanceId } from '@wordpress/compose';
+import { useUserPreferences } from '@woocommerce/data';
export interface AdviceCardProps {
tip?: string;
@@ -22,9 +24,37 @@ export interface AdviceCardProps {
export const AdviceCard: React.FC< AdviceCardProps > = ( {
tip,
image = null,
- isDismissible = false,
- onDismiss = () => {},
+ isDismissible = true,
+ onDismiss,
} ) => {
+ // Generate a unique ID for the advice card.
+ const adviceCardId = useInstanceId(
+ AdviceCard,
+ 'advice-card-instance'
+ ) as string;
+
+ const { updateUserPreferences, product_advice_card_dismissed } =
+ useUserPreferences();
+
+ if ( ! onDismiss ) {
+ onDismiss = () => {
+ updateUserPreferences( {
+ product_advice_card_dismissed: {
+ ...product_advice_card_dismissed,
+ [ adviceCardId ]: 'yes',
+ },
+ } );
+ };
+ }
+
+ // Check if the advice card has been dismissed.
+ if (
+ product_advice_card_dismissed &&
+ product_advice_card_dismissed?.[ adviceCardId ] === 'yes'
+ ) {
+ return null;
+ }
+
return (
{ isDismissible && (
diff --git a/plugins/woocommerce/changelog/update-product-editor-dismiss-linked-product-empty-advices b/plugins/woocommerce/changelog/update-product-editor-dismiss-linked-product-empty-advices
new file mode 100644
index 00000000000..1cca075c8ab
--- /dev/null
+++ b/plugins/woocommerce/changelog/update-product-editor-dismiss-linked-product-empty-advices
@@ -0,0 +1,4 @@
+Significance: patch
+Type: update
+
+[Product Block Editor]: dismiss AdviceCard by clicking close button
diff --git a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php b/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php
index 9c632d0bd65..602844a6d35 100644
--- a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php
+++ b/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php
@@ -185,6 +185,7 @@ class Init {
'variable_product_block_tour_shown',
'local_attributes_notice_dismissed_ids',
'variable_items_without_price_notice_dismissed',
+ 'product_advice_card_dismissed',
)
);
}