Skip to content

Commit 83dd885

Browse files
authored
chore: add changeset for #223 (#234)
Also remove todo comments that were already resolved
1 parent 2eaec65 commit 83dd885

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.changeset/twelve-jokes-dream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@labdigital/commercetools-mock": minor
3+
---
4+
5+
Populate cart.shippingInfo when setShippingMethod is called

src/repositories/cart/actions.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,9 @@ export class CartUpdateHandler
651651
});
652652
}
653653

654-
// TODO: are zones on a single shipping method mutually exclusive in terms of countries in the set? If not, need to determine what to do in case of multiple matches.
654+
// There should only be one zone rate matching the address, since
655+
// Locations cannot be assigned to more than one zone.
656+
// See https://docs.commercetools.com/api/projects/zones#location
655657
const zoneRate = method.zoneRates.find((rate) =>
656658
rate.zone.obj!.locations.some((loc) => loc.country === country),
657659
);
@@ -662,8 +664,9 @@ export class CartUpdateHandler
662664
throw new Error("Zone rate not found");
663665
}
664666

665-
// TODO: how to pick which shipping rate in array to use? All in array are
666-
// matching, but could there be multiple matching rates for a single zone?
667+
// Shipping rates are defined by currency, and getShippingMethodsMatchingCart
668+
// also matches on currency, so there should only be one in the array.
669+
// See https://docs.commercetools.com/api/projects/shippingMethods#zonerate
667670
const shippingRate = zoneRate.shippingRates[0];
668671
if (!shippingRate) {
669672
// This shouldn't happen because getShippingMethodsMatchingCart already

0 commit comments

Comments
 (0)