Repository navigation
SQUARE-398: The order path calls Square's inventory history during checkout, and falls back to a drifting adjustment - #601
Draft
faisal-alvi wants to merge 11 commits into
Draft
faisal-alvi wants to merge 11 commits into
faisal-alvi wants to merge 11 commits into
Conversation
Test the buildWordPress Playground - runs in your browser
ℹ️ Neither can connect to Square: signing in to Square has to send you back to the site, and a site that runs in your browser tab has no public address to come back to. Without a connection the store cannot take payments, sync products or receive webhooks, so the previews show what a merchant sees before connecting. Do not enter Square access tokens or other credentials in a preview. The links stop working 14 days after the last build. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
For orders paid through a non-Square gateway (Cash on delivery, PayPal and so on), the order stock sync asked Square's inventory history on every order and every cancel restock, to decide between an absolute count (item never counted in Square) and a relative adjustment. That put a Square round trip inside every checkout. When the lookup failed, it silently sent an adjustment anyway, so an item Square had never counted went negative in Square (WooCommerce 4, Square -1).
This PR:
Unchanged on purpose, to keep the change small and free of regressions: the adjustment push itself still runs during checkout for known products, and a failed push is still logged and skipped as before; each product's first order after updating makes one history lookup; the refund path for other gateways is unchanged.
Closes https://linear.app/a8c/issue/SQUARE-398/the-order-path-calls-squares-inventory-history-during-checkout-and
Steps to test the changes in this Pull Request:
Setup: WooCommerce as system of record, inventory sync on, Square debug logging on, Cash on delivery enabled, connected to a Square sandbox. Square API calls show in WooCommerce > Status > Logs (square log);
batchRetrieveInventoryChangesis the history lookup.batchRetrieveInventoryChangescall, then aPHYSICAL_COUNTof 4. Square shows 4.ADJUSTMENTof 1 for this checkout, with nobatchRetrieveInventoryChanges. Square shows 3, WooCommerce shows 3.wc_square_resolve_inventory_baselineaction for the product.PHYSICAL_COUNTof 4 from the background action. Square shows 4, WooCommerce shows 4.ADJUSTMENTof 1 is sent, with no history lookup. Square and WooCommerce both show 3.ADJUSTMENTadding the stock back, with no history lookup.Changelog entry