Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
12 changes: 10 additions & 2 deletions packages/reaction-collections/common/collections/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ ReactionCore.Helpers.cartTransform = {
},
cartShipping: function () {
// loop through the cart.shipping, sum shipments.
return parseFloat(getSummary(this.shipping, ["shipmentMethod", "rate"]));
// shipmentMethod could be undefined if we resets workflow from more higher
// stage by adding new item to cart for example
if (typeof this.shipping[0].shipmentMethod === "object") {
return parseFloat(getSummary(this.shipping, ["shipmentMethod", "rate"]));
}
return 0;
},
cartSubTotal: function () {
return getSummary(this.items, ["quantity"], ["variants", "price"]).
Expand All @@ -62,7 +67,10 @@ ReactionCore.Helpers.cartTransform = {
cartTotal: function () {
let subTotal = getSummary(this.items, ["quantity"], ["variants", "price"]);
// loop through the cart.shipping, sum shipments.
let shippingTotal = getSummary(this.shipping, ["shipmentMethod", "rate"]);
let shippingTotal = 0;
if (typeof this.shipping[0].shipmentMethod === "object") {
shippingTotal = getSummary(this.shipping, ["shipmentMethod", "rate"]);
}
shippingTotal = parseFloat(shippingTotal);
// TODO: includes taxes?
if (typeof shippingTotal === "number" && shippingTotal > 0) {
Expand Down