Skip to content
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

[MBL-1783] Don't filter local pickup based on shipping rule #2179

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little concerned that we didn't catch that the pledge summary table was dependent on the shipping rule sooner, considering what this screenshot looked like before, but at least it's fixed now!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion Library/ViewModels/NoShippingPledgeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public class NoShippingPledgeViewModel: NoShippingPledgeViewModelType, NoShippin
context.map { $0.confirmationLabelHidden }
)

let shippingSummaryViewData = Signal.combineLatest(
let shippingSummaryViewDataNonnil = Signal.combineLatest(
selectedShippingRule.skipNil().map(\.location.localizedName),
project.map(\.stats.omitUSCurrencyCode),
project.map { project in
Expand All @@ -252,6 +252,11 @@ public class NoShippingPledgeViewModel: NoShippingPledgeViewModelType, NoShippin
)
.map(PledgeShippingSummaryViewData.init)

let shippingSummaryViewData = Signal.merge(
shippingSummaryViewDataNonnil.wrapInOptional(),
selectedShippingRule.filter(isNil).mapConst(nil)
)

self.configurePledgeRewardsSummaryViewWithData = Signal.combineLatest(
initialData,
pledgeTotal,
Expand Down
11 changes: 1 addition & 10 deletions Library/ViewModels/WithShippingRewardsCollectionViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -482,19 +482,10 @@ private func filteredRewardsByLocation(
let isUnrestrictedShippingReward = reward.isUnRestrictedShippingPreference
let isRestrictedShippingReward = reward.isRestrictedShippingPreference

// return all rewards that are no reward, digital, or ship anywhere in the world.
// Return all rewards that are no reward, digital, local pickup, or ship anywhere in the world.
if rewards.first?.id == reward.id || isRewardLocalOrDigital || isUnrestrictedShippingReward {
shouldDisplayReward = true

// if add on is local pickup, ensure locations are equal.
if isRewardLocalPickup(reward) {
if let rewardLocation = reward.localPickup?.country,
let shippingRuleLocation = shippingRule?.location.country, rewardLocation == shippingRuleLocation {
shouldDisplayReward = true
} else {
shouldDisplayReward = false
}
}
// If restricted shipping, compare against selected shipping location.
} else if isRestrictedShippingReward {
shouldDisplayReward = rewardShipsTo(selectedLocation: shippingRule?.location.id, reward)
Expand Down