File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -602,15 +602,31 @@ private func rewardShipsTo(
602602}
603603
604604private func shippingRule( forReward reward: Reward , selectedLocation location: Location ? ) -> ShippingRule ? {
605+ guard let selectedLocation = location else {
606+ return nil
607+ }
608+
609+ // Whether or not this is a "shippable" reward.
610+ // "No Reward", digital rewards and local pickup rewards are not shippable.
611+ let hasShipping = reward. isRestrictedShippingPreference || reward. isUnRestrictedShippingPreference
612+
605613 guard let rules = reward. shippingRulesExpanded else {
606- let hasShipping = reward. isRestrictedShippingPreference || reward. isUnRestrictedShippingPreference
607614 assert (
608615 !hasShipping,
609- " This reward is shippable, but no shipping rules were set. The backer may not be charged correctly for shipping. "
616+ " This reward is shippable, but no shipping rules were included on the reward. The backer may not be able to complete this pledge. "
617+ )
618+
619+ return nil
620+ }
621+
622+ guard let rule = rules. first ( where: { $0. location. id == selectedLocation. id } ) else {
623+ assert (
624+ !hasShipping,
625+ " This reward is shippable, but no shipping rule matched the selected location. The backer may not be able to complete this pledge. "
610626 )
611627
612628 return nil
613629 }
614630
615- return rules . first ( where : { $0 . location . id == location ? . id } )
631+ return rule
616632}
You can’t perform that action at this time.
0 commit comments