Skip to content

Conversation

@devbodaghe
Copy link
Contributor

Description

This PR fixes a bug where the unmapped attribute banner would persist after an attribute was deleted. Previously, when a user created a new attribute that didn't map to a Meta catalog field, a banner would be displayed. However, if the user then deleted that attribute, the banner would continue to display for up to 30 minutes (the transient timeout period) due to cached data not being cleared.

The fix implements a defensive programming approach by validating the attribute's existence at display time rather than trying to catch deletion events. This ensures the banner automatically disappears when the tracked attribute no longer exists, regardless of how it was deleted.

Related Issue: Fixes banner persistence after attribute deletion

Type of change

  • Fix (non-breaking change which fixes an issue)
  • Add (non-breaking change which adds functionality)
  • Tweak (non-breaking change which fixes code modularity, linting or phpcs issues)
  • Break (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have commented my code, particularly in hard-to-understand areas, if any.
  • I have confirmed that my changes do not introduce any new PHPCS warnings or errors.
  • I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors.
  • I followed general Pull Request best practices. Meta employees to follow this wiki.
  • I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes.
  • I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality.
  • I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this wiki.

Changelog entry

Fix: Unmapped attribute banner no longer persists after attribute deletion

Test Plan

Reproduction Steps (Before Fix)

  1. Navigate to Products > Attributes
  2. Create a new global attribute (e.g., "Test Attribute")
  3. Refresh the page
  4. Confirm that the banner "Your new attribute doesn't directly map to a Meta catalog field" is displayed
  5. Delete the newly created "Test Attribute"
  6. Refresh the page

Expected Result: Banner should not be visible after the attribute is deleted
Actual Result (Before Fix): Banner persists for up to 30 minutes ❌

Verification Steps (After Fix)

  1. Navigate to Products > Attributes
  2. Create a new global attribute (e.g., "Test Attribute")
  3. Refresh the page
  4. Confirm that the banner "Your new attribute doesn't directly map to a Meta catalog field" is displayed ✅
  5. Delete the newly created "Test Attribute"
  6. Refresh the page
  7. Verify that the banner is no longer displayed

Additional Test Scenarios

  • Test with multiple attributes: Create multiple unmapped attributes, delete only the tracked one, verify banner clears
  • Test with attribute mapping: Create an unmapped attribute, map it to a Meta field, verify banner behavior
  • Test banner dismissal: Manually dismiss the banner, verify it doesn't reappear
  • Test attribute recreation: Delete and recreate the same attribute, verify banner behaves correctly

Technical Details

The fix adds validation in display_unmapped_attribute_banner() to check if the tracked attribute still exists before displaying the banner. If the attribute has been deleted, the transients are cleared and the banner is not shown.

Key Changes:

  • Added attribute_exists() method that checks both taxonomy existence and WooCommerce attribute registration
  • Added validation check in display_unmapped_attribute_banner() that clears stale transients when attribute is deleted
  • Removed reliance on deletion hooks, making the solution more robust and defensive

Screenshots

Before

The banner persists even after the attribute "Test Attribute" has been deleted:
![Banner persists after deletion - shows stale banner for deleted attribute]

After

The banner automatically disappears when the attribute is deleted:
![Banner clears after deletion - no banner shown after attribute deletion]

@devbodaghe devbodaghe added the changelog: fix Took care of something that wasn't working. label Oct 21, 2025
@meta-cla meta-cla bot added the CLA Signed label Oct 21, 2025
@github-actions github-actions bot added the type: bug The issue is a confirmed bug. label Oct 21, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2025

📦 Latest Plugin Build

Built at: 2025-10-30T16:25:48.698Z
Commit: 285cdeb
Size: 1.4M

Download: Click here to download the plugin

To download: Click the link above → Scroll to bottom → Download "facebook-for-woocommerce" artifact

@meta-codesync
Copy link

meta-codesync bot commented Oct 21, 2025

@devbodaghe has imported this pull request. If you are a Meta employee, you can view this in D85167019.

@devbodaghe devbodaghe force-pushed the fix/unmapped-attribute-banner-persistence branch from e384a6e to 9ae4a82 Compare October 30, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: fix Took care of something that wasn't working. CLA Signed type: bug The issue is a confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants