Skip to content

Commit

Permalink
[MBL-1783] Don't filter local pickup based on shipping rule (#2179)
Browse files Browse the repository at this point in the history
* Don't filter local pickup based on shipping rule

* Fix test
  • Loading branch information
ifosli authored Oct 17, 2024
1 parent ce18b80 commit 7184ab9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
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

0 comments on commit 7184ab9

Please sign in to comment.