fix(webshipper): allow cancelling WS orders with error status (#1755)
This commit is contained in:
@@ -623,19 +623,17 @@ class WebshipperFulfillmentService extends FulfillmentService {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
if (order) {
|
||||
if (
|
||||
order.data.attributes.status !== "pending" &&
|
||||
order.data.attributes.status !== "missing_rate"
|
||||
) {
|
||||
if (order.data.attributes.status === "cancelled") {
|
||||
return Promise.resolve(order)
|
||||
}
|
||||
throw new Error("Cannot cancel order")
|
||||
}
|
||||
if (this.options_.delete_on_cancel) {
|
||||
return await this.client_.orders.delete(data.id)
|
||||
}
|
||||
|
||||
return this.client_.orders.delete(data.id)
|
||||
return await this.client_.orders.update(data.id, {
|
||||
id: data.id,
|
||||
type: "orders",
|
||||
attributes: {
|
||||
status: "cancelled",
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,16 @@ class Webshipper {
|
||||
},
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
update: async (id, data) => {
|
||||
const path = `/v2/orders/${id}`
|
||||
return this.client_({
|
||||
method: "PATCH",
|
||||
url: path,
|
||||
data: {
|
||||
data,
|
||||
},
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
delete: async (id) => {
|
||||
const path = `/v2/orders/${id}`
|
||||
return this.client_({
|
||||
|
||||
Reference in New Issue
Block a user