added no_notification to fulfillment createShipment
This commit is contained in:
1 parent
fa3cde07ac
commit
c3304edb79
1 file changed
+17
-10
@@ -165,7 +165,7 @@ class FulfillmentService extends BaseService {
|
|||||||
* those partitions.
|
* those partitions.
|
||||||
* @param {Order} order - order to create fulfillment for
|
* @param {Order} order - order to create fulfillment for
|
||||||
* @param {{ item_id: string, quantity: number}[]} itemsToFulfill - the items in the order to fulfill
|
* @param {{ item_id: string, quantity: number}[]} itemsToFulfill - the items in the order to fulfill
|
||||||
* @param {object} config - potential configurations, including metadata to add
|
* @param {object} metadata - potential metadata to add
|
||||||
* @return {Fulfillment[]} the created fulfillments
|
* @return {Fulfillment[]} the created fulfillments
|
||||||
*/
|
*/
|
||||||
async createFulfillment(order, itemsToFulfill, custom = {}) {
|
async createFulfillment(order, itemsToFulfill, custom = {}) {
|
||||||
@@ -180,11 +180,6 @@ class FulfillmentService extends BaseService {
|
|||||||
this.validateFulfillmentLineItem_
|
this.validateFulfillmentLineItem_
|
||||||
)
|
)
|
||||||
|
|
||||||
const { no_notification, ...rest } = custom
|
|
||||||
|
|
||||||
const evaluatedNoNotification =
|
|
||||||
no_notification !== undefined ? no_notification : order.no_notification
|
|
||||||
|
|
||||||
const { shipping_methods } = order
|
const { shipping_methods } = order
|
||||||
|
|
||||||
// partition order items to their dedicated shipping method
|
// partition order items to their dedicated shipping method
|
||||||
@@ -193,10 +188,9 @@ class FulfillmentService extends BaseService {
|
|||||||
const created = await Promise.all(
|
const created = await Promise.all(
|
||||||
fulfillments.map(async ({ shipping_method, items }) => {
|
fulfillments.map(async ({ shipping_method, items }) => {
|
||||||
const ful = fulfillmentRepository.create({
|
const ful = fulfillmentRepository.create({
|
||||||
...rest,
|
...custom,
|
||||||
provider_id: shipping_method.shipping_option.provider_id,
|
provider_id: shipping_method.shipping_option.provider_id,
|
||||||
items: items.map(i => ({ item_id: i.id, quantity: i.quantity })),
|
items: items.map(i => ({ item_id: i.id, quantity: i.quantity })),
|
||||||
no_notification: evaluatedNoNotification,
|
|
||||||
data: {},
|
data: {},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -247,10 +241,19 @@ class FulfillmentService extends BaseService {
|
|||||||
* tracking numbers and potentially more metadata.
|
* tracking numbers and potentially more metadata.
|
||||||
* @param {Order} fulfillmentId - the fulfillment to ship
|
* @param {Order} fulfillmentId - the fulfillment to ship
|
||||||
* @param {TrackingLink[]} trackingNumbers - tracking numbers for the shipment
|
* @param {TrackingLink[]} trackingNumbers - tracking numbers for the shipment
|
||||||
* @param {object} metadata - potential metadata to add
|
* @param {object} config - potential configuration settings, such as no_notification and metadata
|
||||||
* @return {Fulfillment} the shipped fulfillment
|
* @return {Fulfillment} the shipped fulfillment
|
||||||
*/
|
*/
|
||||||
async createShipment(fulfillmentId, trackingLinks, metadata) {
|
async createShipment(
|
||||||
|
fulfillmentId,
|
||||||
|
trackingLinks,
|
||||||
|
config = {
|
||||||
|
metadata: {},
|
||||||
|
no_notification: undefined,
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
const { metadata, no_notification } = config
|
||||||
|
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async manager => {
|
||||||
const fulfillmentRepository = manager.getCustomRepository(
|
const fulfillmentRepository = manager.getCustomRepository(
|
||||||
this.fulfillmentRepository_
|
this.fulfillmentRepository_
|
||||||
@@ -270,6 +273,10 @@ class FulfillmentService extends BaseService {
|
|||||||
trackingLinkRepo.create(tl)
|
trackingLinkRepo.create(tl)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (no_notification) {
|
||||||
|
fulfillment.no_notification = no_notification
|
||||||
|
}
|
||||||
|
|
||||||
fulfillment.metadata = {
|
fulfillment.metadata = {
|
||||||
...fulfillment.metadata,
|
...fulfillment.metadata,
|
||||||
...metadata,
|
...metadata,
|
||||||
|
|||||||
Reference in new issue
Block a user