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

API Pull - Update metadata for Coupons and Product after being notified. #2338

Merged
merged 8 commits into from
Mar 28, 2024

Conversation

jorgemd24
Copy link
Contributor

@jorgemd24 jorgemd24 commented Mar 27, 2024

Changes proposed in this Pull Request:

Part of #2146

Once the products or coupons are notified, we can still update some metadata as we used to when we were pushing the data. This is particularly useful for coupons, as it allows us to inform the user that the coupon has been sent/notified to Google.

This PR adds the following:

  • Once a coupon has been notified, it will update the sync status and sync timestamp.
  • A similar approach will be applied to the products.
  • I've created a new Interface called HelperNotificationInterface for the ProductHelper and CouponHelper. This is because the AbstractItemNotificationJob expects those classes to have certain methods available. By doing this, we can ensure that those methods are indeed available. The catch is that I had to remove some type hints because PHP versions earlier than 8 don't allow multiple types.

Screenshots:

Detailed test instructions:

Coupons

  1. Create a new coupon and set the visibility to Show Coupon on Google.
  2. Go to WC -> Status -> Action Scheduler -> search for: gla/jobs/notifications/coupons/process_item
  3. After the job is finished and has been successfully notified, check the postmeta of the coupon you created. It should have _wc_gla_sync_status = synced and _wc_gla_synced_at set.

image

Products

  1. Create a new product and set the visibility to Sync and Show.
  2. Go to WC -> Status -> Action Scheduler -> search for: gla/jobs/notifications/products/process_item
  3. After the job is finished and has been successfully notified, check the postmeta of the product you created. It should have _wc_gla_sync_status = synced and _wc_gla_synced_at set.

Additional details:

Changelog entry

@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 27, 2024
Copy link

codecov bot commented Mar 27, 2024

Codecov Report

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

Project coverage is 63.9%. Comparing base (b41bad3) to head (3c57d12).
Report is 299 commits behind head on feature/google-api-project.

Additional details and impacted files

Impacted file tree graph

@@                      Coverage Diff                       @@
##             feature/google-api-project   #2338     +/-   ##
==============================================================
+ Coverage                          63.5%   63.9%   +0.4%     
- Complexity                         4391    4443     +52     
==============================================================
  Files                               468     472      +4     
  Lines                             18555   18739    +184     
==============================================================
+ Hits                              11785   11980    +195     
+ Misses                             6770    6759     -11     
Flag Coverage Δ
php-unit-tests 63.9% <54.5%> (+0.4%) ⬆️

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

Files Coverage Δ
...Jobs/Notifications/AbstractItemNotificationJob.php 100.0% <100.0%> (ø)
src/Jobs/Notifications/CouponNotificationJob.php 100.0% <100.0%> (ø)
src/Jobs/Notifications/ProductNotificationJob.php 100.0% <100.0%> (ø)
...Jobs/Notifications/HelperNotificationInterface.php 0.0% <0.0%> (ø)
src/Coupon/CouponHelper.php 67.4% <55.6%> (-2.1%) ⬇️
src/Product/ProductHelper.php 92.1% <33.3%> (-4.0%) ⬇️

... and 10 files with indirect coverage changes

@jorgemd24 jorgemd24 self-assigned this Mar 27, 2024
@jorgemd24 jorgemd24 changed the title Add/mark as notified API Pull - Update metadata for Coupons and Product after being notified. Mar 27, 2024
@jorgemd24 jorgemd24 requested a review from a team March 27, 2024 17:41
@jorgemd24 jorgemd24 marked this pull request as ready for review March 27, 2024 17:45
Copy link
Contributor

@ianlin ianlin left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I can see both coupon and product's metadata were updated. LGTM.

@jorgemd24 jorgemd24 merged commit 7ef7209 into feature/google-api-project Mar 28, 2024
12 checks passed
@jorgemd24 jorgemd24 deleted the add/mark-as-notified branch March 28, 2024 12:54
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