From f5123c2caf3290bd4ba78b898543467bf0eca7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20Soriano?= Date: Tue, 6 Jun 2023 16:33:44 +0200 Subject: [PATCH] Add suggestion from code review Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com> --- docs/HPOS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/HPOS.md b/docs/HPOS.md index 7e9a6860727..fcef1025636 100644 --- a/docs/HPOS.md +++ b/docs/HPOS.md @@ -79,7 +79,7 @@ An exception to the above are the [placeholder records](#placeholder-records): t Order IDs must match in both the authoritative tables and the backup tables, otherwise synchronization wouldn't be possible. The order IDs that are compared for order identification and synchronization purposes are the ones from the `id` field in both the `wp_wc_orders` table and the posts table. -If the posts table is authoritative achieving order id match is easy: the record in `wp_wc_orders` is created with the same id and that's it. However when the new orders tables are authoritative there's a problem: the posts table is used to store multiple types of data, not only orders; and by the time synchronization needs to happen, a non-order post could already exist having the same id as the order to synchronize. +If the posts table is authoritative, achieving an order ID match is easy: the record in `wp_wc_orders` is created with the same ID and that's it. However, when the new orders tables are authoritative there's a problem: the posts table is used to store multiple types of data, not only orders; and by the time synchronization needs to happen, a non-order post could already exist having the same ID as the order to synchronize. To solve this _placeholder records_ are used. Whenever the new orders tables are authoritative and immediate synchronization is disabled, creating a new order will cause a record with post type `shop_order_placehold` and the same id as the order to be created in the posts table; this effectively "reserves" the order id in the posts table. Then at synchronization time the record is filled appropriately and its post type is changed to `shop_order`.