Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Components] americommerce #14229

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
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
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
optional: false,

propDefinition: [
app,
"orderStatusId",
],
},
jcortes marked this conversation as resolved.
Show resolved Hide resolved
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,
},
GTFalcao marked this conversation as resolved.
Show resolved Hide resolved
},
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;
},
GTFalcao marked this conversation as resolved.
Show resolved Hide resolved
};
Loading
Loading