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: true

When this option is enabled, the action will perform the following logic:

  1. Retrieve the last (max 100) orders for the customer.
  2. Check if any of these orders have a meta field created by DG.
  3. If a meta field with the replacement key is found, the order creation process will be stopped.
👍

Check Universal Limits

Default value: true

When this option is enabled, the action will perform the following logic:

  1. Query meta objects of type $app:refund_replacement_order.
  2. Check the number of filtered meta objects by time against the following limits:
    1. Hour Limit: 10
    2. Twelve Hour Limit: 30
    3. Twenty-Four Hour Limit: 50
  3. 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: false

When this option is enabled, the action will perform the following logic:

  1. Search for meta objects of type $app:refund_replacement_address using the shipping address zip code and the billing address zip code. If records are found, the system will check against the following limits:
    1. Fraud Records Limit: 1
    2. 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.

  1. Search for meta objects of type $app:refund_replacement_card_details using the card type, the last 4 digits of the card, and the cardholder's name. If records are found, the system will check against the Fraud 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: false

When 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_alarms DG 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_policy

There are 3 possible values: bypass, decrement_ignoring_policy and decrement_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: false

If this value is true, the action will transfer the quantity of each replaced item from safety_stock to available.

Since the inventory behaviour is set to decrement_ignoring_policy, the available stock 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, the safety_stock quantity for each item will be moved to available.


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
        }
      }
    }
  }
}