Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate shipping methods in first checkout #2880

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of our goals was to eliminate these hard-coded 0th indexes - I'm a bit concerned about introducing these here as it seems like adding technical debt immediately

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