Skip to content

Conversation

@Sidsector9
Copy link
Collaborator

@Sidsector9 Sidsector9 commented Oct 15, 2025

All Submissions:

  • Does your code follow the WooCommerce Sniffs variant of WordPress coding standards?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Will this change require new documentation or changes to existing documentation?

Changes proposed in this Pull Request:

Note: This bug is only reproducible in production

In trunk, option metadata from Square was cached in the wc_square_options_data transient. Some Square responses lacked item_option_data.name when we first fetched them, so those transient entries stored an empty string for name. Because retrieve_options_data() short-circuited whenever the transient existed, later imports kept reusing those incomplete records and never refreshed them. As a result, WooCommerce products imported with attribute values but without attribute labels.

The fix updates retrieve_options_data() so that it treats any cached option missing a name as stale. When it finds an entry like that, it deletes the transient, pulls fresh option data from Square, and rebuilds the cache using get_item_option_name_from_catalog_object(), which falls back to display_name if the primary name is empty. Whenever the importer refreshes these option details, it now stores the result with a TTL, ensuring subsequent imports reuse complete labels instead of blanks.

Closes https://linear.app/a8c/issue/SQUARE-190/square-exportimport-process-loses-attribute-names

Steps to test the changes in this Pull Request:

Please follow the instructions from the Linear ticket.

Changelog entry

Fix - Missing attribute names after Product Import.

$cursor = $response->get_data()->getCursor();
if ( ! $cursor ) {
set_transient( 'wc_square_options_data', $options_data );
set_transient( 'wc_square_options_data', $options_data, DAY_IN_SECONDS );
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matched this with other instances of set_transient( 'wc_square_options_data', $options_data, DAY_IN_SECONDS );

Copy link
Collaborator

@qasumitbagthariya qasumitbagthariya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA Update ✅


I have verified this PR in the SQUARE-190 branch, which has been fixed and is functioning as intended.

I tested the following on this branch:

  • Created a variable product in Square with multiple attributes
  • Synced the product to WooCommerce- worked correctly.
  • Exported the Square catalog to a file.
  • Cleared both Square and WooCommerce catalogs.
  • Imported the exported catalog back into Square.
  • Synced the product again to WooCommerce.

Result: Product Import/synced successfully.

Screen.Recording.2025-10-20.at.2.23.13.PM.mov

Testing Environment

  • WordPress: 6.8.3
  • Theme: Twenty Twenty-Five 1.3
  • WooCommerce - 10.2.2
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS 15.2
  • Branch: SQUARE-190

Steps to Test- As mentioned in the PR description.
Test Results - It is working as expected.
Functional Demo / Screencast -
Special Notes - Ready for UAT
Testing Document status:
Cases related to this Issue/PR are added to the Critical Flow Wiki pages:

  • Yes
  • Not Required/Applicable for this PR

@jeffpaul jeffpaul added this to the Future Release milestone Oct 20, 2025
@qasumitbagthariya
Copy link
Collaborator

Regression / Smoke Test Report ✅

Tested with the smoke-testing branch, it works as expected, similar to the fix-specific branch.

Testing Environment

  • WordPress: 6.8
  • Theme: Twenty Twenty-Four 1.3
  • WooCommerce - 10.3.3
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS 15.2
  • Branch: smoke-testing

Next Step- Ready to Merge 🚀

cc @vikrampm1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants