Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #744 from OpenBazaar/rules
Browse files Browse the repository at this point in the history
Prevent overlapping shipping rule range for quantity discount
  • Loading branch information
cpacia committed Oct 24, 2017
2 parents 403cdab + 9ef13be commit efa03dd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/listings.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,9 @@ func validateListing(listing *pb.Listing, testnet bool) (err error) {
return fmt.Errorf("Shipping rules exceeds max of %d", MaxListItems)
}
for i, rule := range shippingOption.ShippingRules.Rules {
if (shippingOption.ShippingRules.RuleType == pb.Listing_ShippingOption_ShippingRules_FLAT_FEE_QUANTITY_RANGE || shippingOption.ShippingRules.RuleType == pb.Listing_ShippingOption_ShippingRules_FLAT_FEE_WEIGHT_RANGE) && rule.MaxRange <= rule.MinRange {
if (shippingOption.ShippingRules.RuleType == pb.Listing_ShippingOption_ShippingRules_FLAT_FEE_QUANTITY_RANGE ||
shippingOption.ShippingRules.RuleType == pb.Listing_ShippingOption_ShippingRules_FLAT_FEE_WEIGHT_RANGE ||
shippingOption.ShippingRules.RuleType == pb.Listing_ShippingOption_ShippingRules_QUANTITY_DISCOUNT) && rule.MaxRange <= rule.MinRange {
return errors.New("Shipping rule max range cannot be less than or equal to the min range")
}
for x, checkRule := range shippingOption.ShippingRules.Rules {
Expand Down

0 comments on commit efa03dd

Please sign in to comment.