This repository was archived by the owner on Oct 4, 2019. It is now read-only.
Fix variation image setting via ID. #21
Merged
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.
Fixes #18.
Because of how some of the inheritance works, the variations image upload code was calling the wrong code path -- where we wanted this bit of code to run, the v2 code for
set_product_imageswas running instead, sinceWC_REST_Dev_Product_Variations_Controllernow extendsWC_REST_Product_Variations_Controller.To fix this, I'm introducing a proper
set_variation_imagewhich differs a bit anyway. Variations only support one image, not an array of images, so we would never want to set a gallery of images.This wasn't caught by our tests because setting a product image via URL still worked. If you try to set it via ID (which should be valid), it would fail. You can see this if you run the new included test without the other changes.
To test:
Run
phpunitand make sure all tests pass.