Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with inconsistent metadata format #2437

Merged

Conversation

jorgemd24
Copy link
Contributor

Changes proposed in this Pull Request:

Part of #2146

When filtering the private metadata, we use the unset function to remove the private metadata from the response. However, this alters the final response format, changing it from an array of objects to a single object. For example:

Incorrect:

"meta_data": {
            "1": {
                "id": 241,
                "key": "_wc_gla_visibility",
                "value": "sync-and-show"
            },
}

Correct:

"meta_data": [
          {
                "id": 241,
                "key": "_wc_gla_visibility",
                "value": "sync-and-show"
            },
]

Screenshots:

Detailed test instructions:

  1. Choose one product and set the channel visibility to "Sync & Show". Add some private metadata to the product (private metadata = metadata starting with _, for example _my_private_data).
  2. Create some WC REST API credentials and do the following request GET wp-json/wc/v3/products/YOUR_PRODUCT_ID?gla_syncable=1
  3. Without checking this PR, see how the metadata format is incorrect.
  4. Checkout this PR and see the expected response.

Additional details:

Changelog entry

@jorgemd24 jorgemd24 self-assigned this Jun 20, 2024
@github-actions github-actions bot added changelog: fix Took care of something that wasn't working. type: bug The issue is a confirmed bug. labels Jun 20, 2024
@jorgemd24 jorgemd24 marked this pull request as ready for review June 20, 2024 12:45
@jorgemd24 jorgemd24 requested a review from a team June 20, 2024 12:46
Copy link
Contributor

@puntope puntope left a comment

Choose a reason for hiding this comment

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

Thanks @jorgemd24 I can confirm now meta_data is an array of objects.

Screenshot 2024-06-20 at 16 24 04

@jorgemd24 jorgemd24 merged commit a4cf0ed into feature/google-api-project Jun 20, 2024
12 checks passed
@jorgemd24 jorgemd24 deleted the fix/inconsistent_metadata_format branch June 20, 2024 14:28
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. type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants