-
Notifications
You must be signed in to change notification settings - Fork 136
Product details: Keep Shipping card with One Time Shipping available when changing from Subscription to Non-Subscription Type Product #13035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…t type to non-subscription.
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #13035 +/- ##
============================================
+ Coverage 40.23% 40.24% +0.01%
- Complexity 6138 6141 +3
============================================
Files 1280 1280
Lines 74011 74014 +3
Branches 10124 10125 +1
============================================
+ Hits 29779 29788 +9
+ Misses 41645 41634 -11
- Partials 2587 2592 +5 ☔ View full report in Codecov by Sentry. |
…ple' into issue/13033-make-shipping-card-available-when-converting-subscription-to-simple
This reverts commit ae87485.
irfano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these tests, @hafizrahman. I'm not approving or requesting changes at the moment, but I’ve asked some questions to initiate a discussion.
...mmerce/src/main/kotlin/com/woocommerce/android/ui/products/details/ProductDetailViewModel.kt
Show resolved
Hide resolved
...ce/src/test/kotlin/com/woocommerce/android/ui/products/details/ProductDetailViewModelTest.kt
Outdated
Show resolved
Hide resolved
WooCommerce/src/test/kotlin/com/woocommerce/android/ui/products/ProductTestUtils.kt
Outdated
Show resolved
Hide resolved
irfano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, Hafiz! LGTM! 👍🏻
Closes: #13033
Description
This PR handles the edge case bug outlined in #13033: when converting from Simple Subscription or Variable Subscription to Simple Physical product, and the subscription product has "One time shipping" enabled but no other shipping values, then the Shipping card would disappear after the conversion, making it impossible to set Shipping.
Why does this happen?
The issue happens inside
ProductDetailViewModel.onProductTypeChanged(). When it is called,updateProductDraft()does not take into account the existingsubscriptionDraftthat the product has from when it was originally a subscription product. When a Product becomes a simply physical but itssubscriptionDraftvalue still exists, it causes issue with how cards are displayed.With the issue in #13033 specifically, because
subscriptionDraftstill exists, this returns true:woocommerce-android/WooCommerce/src/main/kotlin/com/woocommerce/android/model/ProductAggregate.kt
Lines 22 to 23 in 509b9c9
which then makes the app try to show the Shipping card on
woocommerce-android/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/details/ProductDetailCardBuilder.kt
Lines 473 to 474 in 509b9c9
However because there are no other values aside from One time shipping, and One time shipping display is gated behind Subscription product type check, nothing is shown for this card as there's nothing to show.
And again due to the
hasShippingcheck, it becomes unavailable in "Add more details", too:woocommerce-android/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/details/ProductDetailBottomSheetBuilder.kt
Lines 109 to 110 in 509b9c9
Solution:
The fix in this PR is to reset the data inside
subscriptionDraftwhenever converting to a non simple/variable subscription product. That wayhasShippingwill properly return false and the checks above will behave correctly.Steps to reproduce
Also to test:
Testing information
I tested this in an emulator with API 35.
The tests that have been performed
All the tests listed above.
Images/gif
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: