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

Ensure the product category syncs properly between the Square and WooCommerce store #172

Merged
merged 7 commits into from
Jul 26, 2024

Conversation

iamdharmesh
Copy link
Member

@iamdharmesh iamdharmesh commented Jul 9, 2024

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:

The PR fixes the category reverting issue reported in #156. This issue was introduced due to the Square SDK upgrade, which updated the Square API version. The update added support for multiple categories and deprecated the category_id field. As a result, retrieving the category ID failed, causing categories to revert to the default WooCommerce category during sync. The PR makes the necessary changes to get the category from the Square catalog item and sync it with the Woo store.

Since Square now supports multiple categories, the plugin first looks for the reporting category to import. If the reporting category is not set, it uses the first category from the categories array of the catalog item.

Note

  • The PR does not add support for syncing multiple categories; it fixes the issue with single category sync, ensuring it works as intended. Opened separate issue for adding support for sync multiple categories - [Sync] Add support for syncing multiple categories. #173
  • The newly added fields categories and reporting_category are still in BETA, but the previous category_id field has been removed from the API. Therefore, I have used the newly added fields as suggested in the documentation.

Closes #156

Steps to test the changes in this Pull Request:

  1. Checkout to this PR branch.
  2. Set up SOR to Square.
  3. Import products by clicking on the "Import Products From Square" button.
  4. Verify that the product category does not revert and continues syncing properly.
  5. Test sync thoroughly for all fields (title, price, description, image, category, inventory, etc.) in all types of sync:
    • Product Import
    • Manual Sync
    • Interval polling
  6. Set up WooCommerce as the SOR.
  7. Test sync thoroughly for all fields (title, price, description, image, category, inventory, etc.) in all types of sync:
    • Product create/update in WooCommerce store
    • Manual Sync
    • Interval polling

Changelog entry

Fix - Ensure the product category syncs properly between the Square and WooCommerce store.

@iamdharmesh iamdharmesh self-assigned this Jul 9, 2024
@vikrampm1 vikrampm1 added this to the 4.7.1 milestone Jul 9, 2024
@iamdharmesh iamdharmesh changed the title [WIP] Ensure the product category syncs properly between the Square and WooCommerce store Ensure the product category syncs properly between the Square and WooCommerce store Jul 10, 2024
const response = await createCatalogObject( 'Cap', 'cap', 1350, 'This is a very good cap, no cap.' );
const categoryResponse = await createCategory('Hats');
const categoryId = categoryResponse.catalog_object?.id || '';
const response = await createCatalogObject( 'Cap', 'cap', 1350, 'This is a very good cap, no cap.', categoryId );
Copy link
Contributor

Choose a reason for hiding this comment

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

😂

Copy link
Member Author

Choose a reason for hiding this comment

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

I would like to tag @Sidsector9, the author of this creativity. 🤣

Copy link
Member

Choose a reason for hiding this comment

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

🧢

includes/Handlers/Category.php Outdated Show resolved Hide resolved
includes/Handlers/Category.php Outdated Show resolved Hide resolved
includes/Handlers/Category.php Outdated Show resolved Hide resolved
includes/Handlers/Category.php Outdated Show resolved Hide resolved
includes/Handlers/Category.php Outdated Show resolved Hide resolved
includes/Handlers/Category.php Outdated Show resolved Hide resolved
includes/Handlers/Category.php Outdated Show resolved Hide resolved
includes/Handlers/Category.php Outdated Show resolved Hide resolved
includes/Handlers/Category.php Outdated Show resolved Hide resolved
includes/Sync/Product_Import.php Outdated Show resolved Hide resolved
@iamdharmesh iamdharmesh requested a review from dkotter July 11, 2024 05:51
@qasumitbagthariya
Copy link
Contributor

qasumitbagthariya commented Jul 11, 2024

QA Update ✅


I have checked this issue in the fix/156 branch and the related issue is resolved and working as expected.

I tested the following on this branch:

  • Test sync for all fields (title, price, description, image, category, inventory) in all types of sync:
  • Product Import
  • Manual Sync
  • Interval polling

Testing Environment

  • WordPress: 6.5.5
  • Theme: Storefront 4.6.0
  • Theme: Twenty Twenty-Four 1.1
  • WooCommerce - 9.0.2
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS Ventura 13.3
Screen.Recording.2024-07-11.at.3.06.25.PM.mov
Screen.Recording.2024-07-11.at.2.18.37.PM.mov
Screen.Recording.2024-07-11.at.1.54.07.PM.mov

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

  • Yes
  • Not Required/Applicable for this PR

@qasumitbagthariya qasumitbagthariya requested review from a team and diegocurbelo and removed request for a team July 11, 2024 10:50
@vikrampm1
Copy link
Contributor

@diegocurbelo this PR is ready for your review.

Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

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

Changes look good an tested well 🚢

@vikrampm1 vikrampm1 modified the milestones: 4.7.1, 4.7.2 Jul 22, 2024
@qasumitbagthariya
Copy link
Contributor

Regression / Smoke Test Report ✅

Tested with Archive File created via "php woorelease.phar build repo_URL" (Composer version 2.5.5, npm version 10.7.0, node version 20.15.1)

Status- Working expected with Plugin Archive/Zip file same as fix specific branch.

Testing Environment

  • WordPress: 6.6.1
  • Theme: Twenty Twenty-Four 1.2
  • WooCommerce - 9.1.2
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS Ventura 13.3

Next Step- Ready to Merge 🚀

@vikrampm1 vikrampm1 marked this pull request as ready for review July 26, 2024 17:26
@vikrampm1 vikrampm1 merged commit a2f39ee into trunk Jul 26, 2024
5 of 6 checks passed
@vikrampm1 vikrampm1 deleted the fix/156 branch July 26, 2024 17:27
@vikrampm1 vikrampm1 mentioned this pull request Jul 26, 2024
16 tasks
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.

[HC] Categories reverting to the default category on sync when Square is set as SOR
7 participants