jetpack icon indicating copy to clipboard operation
jetpack copied to clipboard

Sync: HPOS orders sync refunds incorrectly.

Open ibndawood opened this issue 6 months ago • 0 comments

Impacted plugin

Jetpack, Backup

Quick summary

When a post of shop_order_refund is synced, the total_amount column value is always stored as 0.00 in the wc_orders table. This needs to be corrected. The expected total_amount value should be -1 * refund_amount. The refund_amount value is synced but is not stored.

Steps to reproduce

  1. Select an order that is synced already and has a status Pending Payment or On hold.
  2. If such an order does not exist, please create a new order and verify it is synced.
  3. Let's assume the total_amount of the order is 50.0000.
  4. In the WordPress admin panel, click on the order to edit.
  5. In the Order Edit screen, click the Status dropdown and select Refunded to refund the order entirely.
  6. In the local database, verify a new record is created with parent_order_id as the ID of the order refunded.
  7. Verify the total_amount column in the local database equals *1 * total_amount of the parent_order_id. i.e. -50.0000.
  8. Check the record in the synced WPCOM table.
  9. The total_amount is set to 0.00.

A clear and concise description of what you expected to happen.

The total_amount should not be zero and should be equal to the total amount of the parent order in negative.

What actually happened

The total_amount is zero.

Impact

All

Available workarounds?

Yes, easy to implement

If the above answer is "Yes...", outline the workaround.

We can use the jetpack_sync_filtered_hpos_order_data filter to set order_total index which is saved as the total_amount.

Platform (Simple and/or Atomic)

No response

Logs or notes

No response

ibndawood avatar Aug 26 '24 08:08 ibndawood