woocommerce / woocommerce-square

Square POS and Payments Integration
https://woo.com/products/square
Other
11 stars 7 forks source link

Fix product duplication issue on the Square side when WooCommerce is SOR. #246

Open iamdharmesh opened 3 days ago

iamdharmesh commented 3 days ago

All Submissions:


Changes proposed in this Pull Request:

As reported in #232, when uploading or syncing new products with Square, issues arise when there are a large number of products to sync. The product sync fails, and duplicate products are created on the Square side. This occurred because the upsert limit was too high (500) for new products. As a result, the sync process experiences 429 Too Many Requests errors sometimes. Additionally, in cases of successful requests, time and memory limitations prevent the Square item data from being stored in the product meta, causing the same product to be sent again for upsert, which leads to duplicate products. (It’s worth noting that Square allows the creation of products with the same SKU, which is unusual.)

This PR fixes the upsert process here and reduces the upsert limit from 500 to 25, which enables the plugin to complete the upsert requests and update product data based on the response.

Closes #232. Closes #247. Closes #108.

Steps to test the changes in this Pull Request:

  1. Configure the plugin and set WooCommerce as the Source of Record (SOR).
  2. Create a large number of dummy products (2,000–3,000) using WooCommerce Smooth Generator or any other dummy data generation tool or just import products using CSV.
  3. Enable sync for all products. (This could be done by passing "yes" under the "Sync with Square" column in CSV import in step 2)
  4. Start a manual sync from the Square settings.
  5. Verify that the products are properly synced with Square and that no duplicate products are created on the Square side.

#108

  1. Try sending too many requests to Square by following the steps here.
  2. Sending too many requests will result in 429 errors in sync.
  3. Verify no duplicate products are created on the Square side.

#247

  1. Enable debug logs from Square settings.
  2. Checkout to trunk branch
  3. Visit WooCommerce > Settings > Square > Update page.
  4. Notice there are logs for the listLocations API call.
  5. Checkout to this branch.
  6. Visit WooCommerce > Settings > Square > Update page.
  7. Verify there is no log for the listLocations API call.

Changelog entry

Fix - Resolved the product duplication issue on the Square side when WooCommerce is set to SOR.

iamdharmesh commented 2 days ago

@dkotter, I’ve implemented the retry for the 429 on this PR. Can you please review it quickly? Apologies for the re-review request. Thanks.