[WOOMOB-3229] Send image deletion when a variation image is removed#16245
[WOOMOB-3229] Send image deletion when a variation image is removed#16245irfano wants to merge 17 commits into
Conversation
There was a problem hiding this comment.
AI Code Review - Found 1 potential issue
The core fix is sound and consistent end-to-end: a removed image maps to a blank WCProductVariationModel.image, the mapper now sends {"id":0} (WCProductImageModel.toJson correctly omits src/name for id 0), and the ViewModel's updated variation.image == null guard matches how removal is represented (Optional(null) → blank image). The isJsonNull guard in the API response and the ifEmpty refactor are correct. Good unit coverage on both the mapper and the ViewModel error path.
PR housekeeping
- This is the WooCommerce Android (Kotlin) repo; reviewed against
AGENTS.md/CLAUDE.mdFluxC + store-app conventions rather than the PHP/WooCommerce-core guidance.
Automatic review · claude-opus-4-8 · Workflow run
How to reply to a finding
Reply on this review (or inline at the line the finding refers to) with one of:
@claude addressed- I made the change. Bot verifies against the next diff before marking resolved.@claude rejected: <reason>- Will not fix; reason gets quoted on the next review.@claude not-applicable- Finding does not apply (wrong file, already covered elsewhere, etc.).
The bot honours these on the next review pass.
|
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #16245 +/- ##
=========================================
Coverage 41.15% 41.16%
- Complexity 13501 13508 +7
=========================================
Files 2503 2503
Lines 146465 146468 +3
Branches 21761 21761
=========================================
+ Hits 60278 60288 +10
+ Misses 80089 80054 -35
- Partials 6098 6126 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AdamGrzybkowski
left a comment
There was a problem hiding this comment.
LGTM 👍 but:
Both variation fetches now use the REST edit context, GET wc/v3/products//variations/ for the edit screen and GET wc/v3/products//variations for the editing list, so the response carries the variation's own image instead of falling back to the parent product's image.
I think it's worth confirming with the Peacock team because the fetchSingleVariation is also used by POS.
…e-removal' into issue/WOOMOB-3229-variation-image-removal
Generated by 🚫 Danger |
Good point, Adam. This slightly changes the behavior of how variation images are displayed on the order details and POS screens. Also, this PR uses the existing image field in the DB, but populates it from two different sources (edit and view context fetches). I fixed that in a follow-up PR. I’ll merge this after the follow-up is approved, and I’ll ask Peacock to review the follow-up PR (#16272). |

Fixes WOOMOB-3229
Description
Removing a variation's image never reached the store: the update mapper only included the
imagefield when the new image was non-blank, so the removal was silently dropped and the image reappeared after the refresh. This was a regression from the bulk-create-variations refactor.The mapper now sends
image: {id: 0}when the image is cleared, which WooCommerce treats as deleting the variation image. Both variation fetches now use the RESTeditcontext,GET wc/v3/products/<id>/variations/<id>for the edit screen andGET wc/v3/products/<id>/variationsfor the editing list, so the response carries the variation's own image instead of falling back to the parent product's image. This matches how the WooCommerce admin loads variations for editing: the variation's own image, or a placeholder. Other surfaces (the order creation variation picker and the POS lookup) keep the defaultviewcontext, so the locally cached variation image carries the context of whichever fetch last wrote it. Anullimage in the response is now mapped to an empty string instead of the literal"null"it used to produce.On stores older than WooCommerce 4.7, image removal isn't supported. The dedicated error message for this case was never actually shown due to a separate bug in its display condition; this PR fixes that too, so the app now shows it instead of a generic update error.
Test Steps
On a store with a variable product whose variation has an image:
Images/gif
WooCommerce below 4.7 error message on removing a variation image.

RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.