Skip to content

Commit

Permalink
Merge pull request #13021 from woocommerce/issue/12785-subs-one-time-…
Browse files Browse the repository at this point in the history
…shipping-state

Improve logic to display "One time shipping" label on Product Details
  • Loading branch information
hafizrahman authored Nov 29, 2024
2 parents 4833cd3 + f109bb9 commit 4d873d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
)

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4d873d6

Please sign in to comment.