Skip to content

Commit

Permalink
add flat rate shipping methods only when a cart has all the needed in…
Browse files Browse the repository at this point in the history
…fo (#2880)
  • Loading branch information
foladipo authored and brent-hoover committed Sep 18, 2017
1 parent 5cf5838 commit 670ed43
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions imports/plugins/included/shipping-rates/server/hooks/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ function getShippingRates(previousQueryResults, cart) {
return previousQueryResults;
}
}
if (!(cart.shipping && cart.shipping[0] && cart.shipping[0].address)) {
const errorDetails = {
requestStatus: "error",
shippingProvider: "shippo",
message: "The 'shipping' property of this cart is either missing or incomplete."
};
rates.push(errorDetails);
return [rates, retrialTargets];
}
if (!(cart.items && cart.items[0] && cart.items[0].parcel)) {
const errorDetails = {
requestStatus: "error",
shippingProvider: "shippo",
message: "This cart has no items, or the first item has no 'parcel' property."
};
return [[errorDetails], []];
}

let merchantShippingRates = false;
const marketplaceSettings = Reaction.getMarketplaceSettings();
Expand Down

0 comments on commit 670ed43

Please sign in to comment.