-
Notifications
You must be signed in to change notification settings - Fork 132
Issue/6585 onboarding sl banner display logic #6620
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
Merged
JorgeMucientes
merged 13 commits into
trunk
from
issue/6585-onboarding-sl-banner-display-logic
Jun 1, 2022
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e02af89
Add logic to control when to display install WC Shipping banner
JorgeMucientes 3afc4e5
Remove redundant SAM-constructors
JorgeMucientes 75ef65d
Remove redundant code from OrderDetailViewModel and use ShippingLabel…
JorgeMucientes 05a8173
Fix tests after extracting logic out of OrderDetailViewModel
JorgeMucientes 2368475
Remove unnecessary stubbings from tests
JorgeMucientes 93e54d7
Move feature flag to fragment for testing purposes
JorgeMucientes 4a0159a
Update logic for displaying banner to include ipp eligibility
JorgeMucientes d9f780d
Add unit tests for ShippingLabelOnboardingRepository
JorgeMucientes 25c499b
Fix detekt issues
JorgeMucientes 4a923e5
Merge branch 'issue/6585-onboarding-sl-banner-ui' into issue/6585-onb…
JorgeMucientes 17d2e04
Fix bad imports after merge
JorgeMucientes 9768703
Fix bad renaming after merge
JorgeMucientes 0f20123
Fix tests after bad merge
JorgeMucientes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ain/kotlin/com/woocommerce/android/ui/orders/details/ShippingLabelOnboardingRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.woocommerce.android.ui.orders.details | ||
|
||
import com.woocommerce.android.extensions.semverCompareTo | ||
import com.woocommerce.android.model.Order | ||
import javax.inject.Inject | ||
|
||
class ShippingLabelOnboardingRepository @Inject constructor( | ||
private val orderDetailRepository: OrderDetailRepository | ||
) { | ||
companion object { | ||
// The required version to support shipping label creation | ||
const val SUPPORTED_WCS_VERSION = "1.25.11" | ||
const val SUPPORTED_WCS_CURRENCY = "USD" | ||
const val SUPPORTED_WCS_COUNTRY = "US" | ||
} | ||
|
||
val isShippingPluginReady: Boolean by lazy { | ||
val pluginInfo = orderDetailRepository.getWooServicesPluginInfo() | ||
pluginInfo.isInstalled && pluginInfo.isActive && | ||
(pluginInfo.version ?: "0.0.0").semverCompareTo(SUPPORTED_WCS_VERSION) >= 0 | ||
} | ||
|
||
fun shouldShowWcShippingBanner(order: Order, eligibleForIpp: Boolean): Boolean = | ||
!isShippingPluginReady && | ||
orderDetailRepository.getStoreCountryCode() == SUPPORTED_WCS_COUNTRY && | ||
order.currency == SUPPORTED_WCS_CURRENCY && | ||
!order.isCashPayment && | ||
!eligibleForIpp && | ||
!hasVirtualProductsOnly(order) | ||
|
||
private fun hasVirtualProductsOnly(order: Order): Boolean { | ||
return if (order.items.isNotEmpty()) { | ||
val remoteProductIds = order.getProductIds() | ||
orderDetailRepository.hasVirtualProductsOnly(remoteProductIds) | ||
} else false | ||
} | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.