@idigi/reaction-plugin-shipments-flat-rate
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "@idigi/reaction-plugin-shipments-flat-rate", | ||
"description": "Flat Rate Shipments plugin for the Reaction API", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "type": "module", |
@@ -6,2 +6,3 @@ import Random from "@reactioncommerce/random"; | ||
addressId, | ||
fulfillmentId, | ||
cartId, | ||
@@ -24,4 +25,21 @@ cartToken, | ||
let didModify = false; | ||
if (!(cart.shipping || []).length) { | ||
cart.shipping = [ | ||
{ | ||
_id: fulfillmentId || Random.id(), | ||
shopId: cart.shopId, | ||
type: "shipping", | ||
...update, | ||
}, | ||
]; | ||
didModify = true; | ||
} | ||
///|\\\|///|\\\|///|\\\ | ||
/// Update | ||
///|\\\|///|\\\|///|\\\ | ||
const updatedFulfillmentGroups = (cart.shipping || []).map((group) => { | ||
if (group.type === type) { | ||
if ( | ||
(fulfillmentId && fulfillmentId === group._id) || | ||
(!fulfillmentId && group.type === type) | ||
) { | ||
didModify = true; | ||
@@ -28,0 +46,0 @@ return { _id: Random.id(), shopId: cart.shopId, ...group, ...update }; |
@@ -1,2 +0,2 @@ | ||
import { decodeAddressOpaqueId, decodeCartOpaqueId } from "../../xforms/id.js"; | ||
import { decodeAddressOpaqueId, decodeCartOpaqueId,decodeFulfillmentGroupOpaqueId } from "../../xforms/id.js"; | ||
@@ -28,2 +28,3 @@ /** | ||
cartId: opaqueCartId, | ||
fulfillmentId: opaqueFulfillmentId, | ||
clientMutationId = null, | ||
@@ -35,2 +36,3 @@ ...more | ||
const cartId = decodeCartOpaqueId(opaqueCartId); | ||
const fulfillmentId = decodeFulfillmentGroupOpaqueId(opaqueFulfillmentId); | ||
if (address && address._id) address._id = decodeAddressOpaqueId(address._id); | ||
@@ -42,2 +44,3 @@ | ||
cartId, | ||
fulfillmentId, | ||
...more, | ||
@@ -44,0 +47,0 @@ }); |
Sorry, the diff of this file is not supported yet
172214
3009