diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 2e6f8a87175..365f7acba1f 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -3,6 +3,7 @@ *** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too. 21.3 ----- +- [*] "One time shipping" label in Product Subscriptions now matches its availability state correctly. [https://github.com/woocommerce/woocommerce-android/pull/13021] - [Internal] Refactored IPP Payment flow to allow customizing payment collection UI in POS [https://github.com/woocommerce/woocommerce-android/pull/13014] - [*] Blaze Campaign Intro screen now offers creating a new product if the site has no products yet [https://github.com/woocommerce/woocommerce-android/pull/13001] diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/details/ProductDetailCardBuilder.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/details/ProductDetailCardBuilder.kt index 783eb50732c..2f00df7c080 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/details/ProductDetailCardBuilder.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/details/ProductDetailCardBuilder.kt @@ -483,11 +483,7 @@ class ProductDetailCardBuilder( ), Pair( resources.getString(string.subscription_one_time_shipping), - if (subscription?.oneTimeShipping == true) { - resources.getString(string.subscription_one_time_shipping_enabled) - } else { - "" - } + buildOneTimeShippingDescription(subscription) ) ) @@ -533,6 +529,20 @@ class ProductDetailCardBuilder( } } + // Builds "One time shipping" description label. This label is affected by: + // - Support state: Checked with `supportsOneTimeShipping`. One time shipping may not be supported, + // for example during free trials. + // - Toggle state: Checked with `oneTimeShipping`. When shipping is supported, it can be toggled on/off. + // + // We only show "Enabled" when shipping is both supported AND enabled. + // In all other cases (not supported, or supported but disabled), we show nothing. + private fun buildOneTimeShippingDescription(subscription: SubscriptionDetails?) = + if (subscription != null && subscription.supportsOneTimeShipping && subscription.oneTimeShipping) { + resources.getString(string.subscription_one_time_shipping_enabled) + } else { + "" + } + // enable editing external product link private fun Product.externalLink(): ProductProperty? { return if (this.productType == EXTERNAL) {