Shopify Create Replacement Order v3
Create a replacement order for an existing Shopify order.
In order for this action to work 3 meta object definitions have to be created for the Shopify store.
Inputs
| Name | Type | Description |
|---|---|---|
| Shopify Token | Credentials | Shopify API token |
| Shopify Domain | String | Shopify domain |
| Order ID | String | Shopify order ID |
| Replacement Reason | String | Original order ID to created a replacement fort |
| Replacement Reason | String | The replacement reason that will be added to the discount code which is visible to the customer and also added to the orders notesr |
| Check for Previous Replacements | Optional Boolean | Whether to check for previous replacements for the order customer. Default: true |
| Check Universal Limits | Optional Boolean | Whether to check for domain wide number of replacements during last hour, 12 hours and 24 hours. Default: true |
| Check Universal Amount Limits | Optional Boolean | Whether to check amount refunded in the last 24 hours. Linked to: Check Universal Limits. Default: false |
| Check for Fraud Limits | Optional Boolean | Whether to check for shipping/billing addresses and card details limits. Default: false |
| Send Notifications to DG Slack channel | Optional Boolean | Whether to send notifications to the DG Slack channel if the universal limits were exceeded. Default: false |
| Billing Address | Optional Object | Shopify billing address object to overwrite the order address. Default: order billing address |
| Shipping Address | Optional Object | Shopify shipping address object to overwrite the order address. Default: order shipping address |
| Shipping Lines | Optional List | Shopify shipping lines. Default: order shipping lines with price set to zero |
| Line Items | Optional List | Shopify line items. Default: order line items with variant id and quantity |
| Discount Type | Optional String | Discount type for line items. Use 'full' option to apply full discount to all line items or custom or override with your own discount codes. Default: full Possible values: full, custom |
| Discount Codes | Optional Object | List of shopify discounts for custom discount type |
| Update Order Note? | Optional Boolean | Whether to update the order note on the replacement order. Default: true |
| Inventory Behaviour | Optional String | Inventory behaviour for the replacement order. Default: Decrement Obeying Policy Possible values: bypass, decrement_ignoring_policy, decrement_obeying_policy |
| Fraud Records Limit | Optional Number | Limit for replacements created for address/card number/card name. Linked to: Check for Fraud Limits. Default: 1 |
| Fraud Addresses Limit | Optional Number | Limit for replacements created from different addresses for a specific zip code. Linked to: Check for Fraud Limits. Default: 5 |
| Hour Limit | Optional Number | Hour limit for replacements created. Linked to: Check Universal Limits. Default: 10 |
| Twelve Hour Limit | Optional Number | Twelve hour limit for replacements created. Linked to: Check Universal Limits. Default: 30 |
| Twenty Four Hour Limit | Optional Number | Twenty four hour limit for replacements created. Linked to: Check Universal Limits. Default: 50 |
| Twenty Four Hour Amount Limit | Optional Number | Twenty four hour amount limit for replacements created. Linked to: Check Universal Amount Limits. Default: 1000 |
| Order Name Prefix | Optional String | Order name prix to append to the original order number in case it's provided |
| Use Safety Stock | Optional Boolen | Whether to use the safety stock instead of available. Default: false |
Check for Previous Replacements
Default value:
trueWhen this option is enabled, the action will perform the following logic:
- Retrieve the last (max 100) orders for the customer.
- Check if any of these orders have a meta field created by DG.
- If a meta field with the replacement key is found, the order creation process will be stopped.
Check Universal Limits
Default value:
trueWhen this option is enabled, the action will perform the following logic:
- Query meta objects of type
$app:refund_replacement_order.- Check the number of filtered meta objects by time against the following limits:
- Hour Limit: 10
- Twelve Hour Limit: 30
- Twenty-Four Hour Limit: 50
- If any of these limits are exceeded, the order creation process will be stopped.
Additionally, if Check Universal Amount Limits is enabled, the action will check the total amount of money replaced within the twenty-four hour limit against the Twenty Four Hour Amount Limit (default value: 1000). If this amount is exceeded, the order creation process will be stopped.
Check for Fraud Limits
Default value:
falseWhen this option is enabled, the action will perform the following logic:
- Search for meta objects of type
$app:refund_replacement_addressusing the shipping address zip code and the billing address zip code. If records are found, the system will check against the following limits:
- Fraud Records Limit: 1
- Fraud Addresses Limit: 5
The Fraud Addresses Limit is used to check how many distinct address lines are tied to the same zip code. If either of these limits is exceeded, the order creation process will be stopped.
- Search for meta objects of type
$app:refund_replacement_card_detailsusing the card type, the last 4 digits of the card, and the cardholder's name. If records are found, the system will check against theFraud Records Limit(default value: 1). If this limit is exceeded, the order creation process will be stopped.
Send Notifications to DG Slack channel
Default value:
falseWhen this option is enabled, the action will perform the following logic:
If the universal limits are exceeded, a notification will be sent to the
#shopify_r_r_alarmsDG Slack channel.
Order Name Prefix
Order name prefix is an optional input. In case it's provided it will be appended after the initial prefix.
Example:original_name = "#123" order_name_prefix = "R" updated_name = "#R123"
Order Details
Billing Address, Shipping Address, Line Items, Shipping Lines, are all optional inputs. In case they are not provided the data will be copied from the original order.
Discount Codes
Discount Codes is an optional input and will be considered only if it's provided and the Discount Type is custom.
Hour Limit, Twelve Hour Limit, Twenty Four Hour Limit, Twenty Four Hour Amount Limit, Fraud Records Limit, Fraud Addresses Limit
These are optional inputs, each of which has a default value. They will be considered only if the inputs that they are linked with are truthful.
Hour Limit: 10
Twelve Hour Limit: 30
Twenty Four Hour Limit: 50
Fraud Records Limit: 1
Fraud Addresses Limit: 5
Inventory Behaviour
Default value:
decrement_obeying_policyThere are 3 possible values:
bypass,decrement_ignoring_policyanddecrement_obeying_policy.bypass: The stock levels are not changed.
decrement_ignoring_policy: Stock levels are adjusted, but the replacement order is created even if there is no stock available.
decrement_ignoring_policy: Stock levels are adjusted, the replacement order will not be created if there is no stock.
Use Safety Stock
Default value:
falseIf this value is
true, the action will transfer the quantity of each replaced item fromsafety_stocktoavailable.Since the
inventory behaviouris set todecrement_ignoring_policy, theavailablestock level is initially reduced. Once the replacement order is created, the action will retrieve the assigned locations from the fulfillment orders for each item. Then, thesafety_stockquantity for each item will be moved toavailable.
Outputs
| Name | Type | Description |
|---|---|---|
| Replacement Order Created | Boolean | Whether the replacement order was created |
| Order ID | Number | Replacement order ID |
| Blocked by Safety Checks | Boolean | Whether the replacement was blocked by safety/fraud checks |
| Replacement Note Created | Boolean | Whether the replacement note was created |
| Replacement Metafields Created | Boolean | Whether the replacement metafields were created |
| Replacement Metaobject Created | Boolean | Whether the replacement metaobject was created |
| Fraud Prevention Meta Objects Created | Boolean | Whether the fraud prevention addresses/card details meta objects were created |
| Replacement Meta Object Updated | Boolean | Whether the replacement meta object was updated after the order was created |
| Inventory Move Successful | Boolean | Whether successfully moved the safety inventory to available after replacement order creation. Linked to: Use Safety Stock |
| Order | Object | Replacement order |
Replacement Order
A replacement order is created only if all the safety checks are passed and the initial replacement meta object is created.
Replacement Meta Object Schema
mutation {
metaobjectDefinitionCreate(
definition: {
type: "$app:refund_replacement_order"
access: { admin: MERCHANT_READ, storefront: NONE }
fieldDefinitions: [
{ key: "order_id", name: "Order ID", type: "number_integer" }
{ key: "status", name: "Status", type: "single_line_text_field" }
{ key: "completed", name: "Operation Completed?", type: "boolean" }
{ key: "start_date", name: "Date and Time Refund/Replacement Initiated", type: "date_time" }
{ key: "reason", name: "Reason for refund/replacement", type: "single_line_text_field" }
{ key: "amount", name: "Amount refunded/replaced", type: "number_integer" }
{ key: "customer_id", name: "Shopify Customer ID", type: "number_integer" }
{ key: "customer_email", name: "Customer Email", type: "single_line_text_field" }
{ key: "shipping_address_zip", name: "Shipping Address ZIP Code", type: "single_line_text_field" }
{ key: "billing_address_zip", name: "Billing Address ZIP Code", type: "single_line_text_field" }
{ key: "ip_address", name: "Order IP Address", type: "single_line_text_field" }
{ key: "operation_type", name: "Operation Type: Refund or Replacement", type: "single_line_text_field" }
{ key: "type", name: "Type: Full or Partial", type: "single_line_text_field" }
{ key: "shipping_address", name: "Shipping Address", type: "json" }
{ key: "billing_address", name: "Billing Address", type: "json" }
{ key: "line_items", name: "Line Items", type: "json" }
]
}
) {
metaobjectDefinition {
id
type
fieldDefinitions {
key
name
type {
name
}
}
}
}
}
Addresses Meta Object Schema
mutation {
metaobjectDefinitionCreate(
definition: {
type: "$app:refund_replacement_address"
access: { admin: MERCHANT_READ, storefront: NONE }
fieldDefinitions: [
{ key: "address_list", name: "List of Addresses", type: "json" }
]
}
) {
metaobjectDefinition {
id
type
fieldDefinitions {
key
name
type {
name
}
}
}
}
}
Card Details Meta Object Schema
mutation {
metaobjectDefinitionCreate(
definition: {
type: "$app:refund_replacement_card_details"
access: { admin: MERCHANT_READ, storefront: NONE }
fieldDefinitions: [
{ key: "count", name: "Number of Operations", type: "json" }
]
}
) {
metaobjectDefinition {
id
type
fieldDefinitions {
key
name
type {
name
}
}
}
}
}
Updated over 1 year ago
