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

Add target audiences and shipping times in the settings/general endpoint. #2342

Merged

Conversation

jorgemd24
Copy link
Contributor

@jorgemd24 jorgemd24 commented Mar 28, 2024

Changes proposed in this Pull Request:

Part of #2146

As part of the new mechanism for syncing merchant data with Google Merchant Center, we need to make some GLA Options accessible, such as the target audience and shipping times.

This PR adds the target audience and shipping time to the response of wp-json/wc/v3/settings/general

Initially, my idea was to use the filter woocommerce_settings- . $group_id to add a new group of settings. However, this filter can only be used for Options (which should be fine for the target audience but not for the shipping times). Additionally, the filter woocommerce_settings- doesn't provide the Request Object param so I decided to use the filter rest_request_after_callbacks which makes it easier to verify if the request is made from the proxied endpoints.

https://github.com/woocommerce/woocommerce/blob/af03815134385c72feb7a70abc597eca57442820/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-setting-options-controller.php#L79

Screenshots:

Detailed test instructions:

  1. Get WC REST API credentials, or alternatively, you can use your sandbox and authorize your WPCOM App in WPCOM.
  2. Make a request to GET /wp-json/wc/v3/settings/general?gla_syncable=1. If using the WPCOM proxy, use wpcom/v2/sites/YOUR_BLOG_ID/wc/v3/settings/general.
  3. Verify that the response contains two new fields: gla_target_audience and gla_shipping_times.
  4. Check that if the parameter gla_syncable=1 is not included in the URL, for example: GET /wp-json/wc/v3/settings/general, it will not add those two fields. Note: If you make the request from WPCOM, it will always add the query parameter.

Additional details:

Changelog entry

@jorgemd24 jorgemd24 self-assigned this Mar 28, 2024
@github-actions github-actions bot added changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement. labels Mar 28, 2024
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 61.90476% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 64.1%. Comparing base (30bc13b) to head (8ceb779).
Report is 13 commits behind head on feature/google-api-project.

Additional details and impacted files

Impacted file tree graph

@@                      Coverage Diff                       @@
##             feature/google-api-project   #2342     +/-   ##
==============================================================
+ Coverage                          62.5%   64.1%   +1.5%     
+ Complexity                         4466    4450     -16     
==============================================================
  Files                               764     472    -292     
  Lines                             22581   18775   -3806     
  Branches                            543       0    -543     
==============================================================
- Hits                              14121   12031   -2090     
+ Misses                             8003    6744   -1259     
+ Partials                            457       0    -457     
Flag Coverage Δ
js-unit-tests ?
php-unit-tests 64.1% <61.9%> (+0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...ependencyManagement/IntegrationServiceProvider.php 0.0% <0.0%> (ø)
src/DB/Query/ShippingTimeQuery.php 31.2% <50.0%> (+17.0%) ⬆️
src/Integration/WPCOMProxy.php 65.4% <67.7%> (-0.8%) ⬇️

... and 317 files with indirect coverage changes

@jorgemd24 jorgemd24 requested a review from a team March 28, 2024 13:12
@jorgemd24 jorgemd24 marked this pull request as ready for review March 28, 2024 13:12
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.

LGTM ✅ Thanks @jorgemd24

When gla_syncable=1
Screenshot 2024-03-29 at 11 03 32

I left a comment regarding the since tag, but approved in advance.

* Whether the data should be filtered.
* Register the callbacks.
*/
protected function register_callbacks() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed @since param

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually since all the class is new maybe we can add it at the top of the class

@jorgemd24 jorgemd24 merged commit 9031c8c into feature/google-api-project Apr 2, 2024
12 checks passed
@jorgemd24 jorgemd24 deleted the add/target-audience-and-shipping-times branch April 2, 2024 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants