-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,570 additions
and
8 deletions.
There are no files selected for viewing
132 changes: 132 additions & 0 deletions
132
components/americommerce/actions/change-order-status/change-order-status.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import app from "../../americommerce.app.mjs"; | ||
|
||
export default { | ||
key: "americommerce-change-order-status", | ||
name: "Change Order Status", | ||
description: "Changes the status of an existing order. [See the documentation](https://developers.cart.com/docs/rest-api/6898d9f254dfb-update-an-order-status).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
orderStatusId: { | ||
optional: false, | ||
propDefinition: [ | ||
app, | ||
"orderStatusId", | ||
], | ||
}, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "The name of the order status.", | ||
optional: true, | ||
}, | ||
isOpen: { | ||
type: "boolean", | ||
label: "Is Open", | ||
description: "Indicates whether the order status is open.", | ||
optional: true, | ||
}, | ||
isDeclined: { | ||
type: "boolean", | ||
label: "Is Declined", | ||
description: "Indicates whether the order status is declined.", | ||
optional: true, | ||
}, | ||
isCancelled: { | ||
type: "boolean", | ||
label: "Is Cancelled", | ||
description: "Indicates whether the order status is cancelled.", | ||
optional: true, | ||
}, | ||
isShipped: { | ||
type: "boolean", | ||
label: "Is Shipped", | ||
description: "Indicates whether the order status is shipped.", | ||
optional: true, | ||
}, | ||
color: { | ||
type: "string", | ||
label: "Color", | ||
description: "The color of the order status.", | ||
optional: true, | ||
}, | ||
emailTemplateId: { | ||
propDefinition: [ | ||
app, | ||
"emailTemplateId", | ||
], | ||
}, | ||
isFullyRefunded: { | ||
type: "boolean", | ||
label: "Is Fully Refunded", | ||
description: "Indicates whether the order status is fully refunded.", | ||
optional: true, | ||
}, | ||
isPartiallyRefunded: { | ||
type: "boolean", | ||
label: "Is Partially Refunded", | ||
description: "Indicates whether the order status is partially refunded.", | ||
optional: true, | ||
}, | ||
isQuoteStatus: { | ||
type: "boolean", | ||
label: "Is Quote Status", | ||
description: "Indicates whether the order status is a quote status.", | ||
optional: true, | ||
}, | ||
isPartiallyShipped: { | ||
type: "boolean", | ||
label: "Is Partially Shipped", | ||
description: "Indicates whether the order status is partially shipped.", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
changeOrderStatus({ | ||
orderStatusId, ...args | ||
} = {}) { | ||
return this.app.put({ | ||
path: `/order_statuses/${orderStatusId}`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
changeOrderStatus, | ||
orderStatusId, | ||
name, | ||
isOpen, | ||
isDeclined, | ||
isCancelled, | ||
isShipped, | ||
color, | ||
emailTemplateId, | ||
isFullyRefunded, | ||
isPartiallyRefunded, | ||
isQuoteStatus, | ||
isPartiallyShipped, | ||
} = this; | ||
|
||
const response = await changeOrderStatus({ | ||
$, | ||
orderStatusId, | ||
data: { | ||
name, | ||
is_open: isOpen, | ||
is_declined: isDeclined, | ||
is_cancelled: isCancelled, | ||
is_shipped: isShipped, | ||
color, | ||
email_template_id: emailTemplateId, | ||
is_fully_refunded: isFullyRefunded, | ||
is_partially_refunded: isPartiallyRefunded, | ||
is_quote_status: isQuoteStatus, | ||
is_partially_shipped: isPartiallyShipped, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully changed the order status with ID \`${response.id}\`.`); | ||
return response; | ||
}, | ||
}; |
Oops, something went wrong.