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

NameTypeDescription
Shopify TokenCredentialsShopify API token
Shopify DomainStringShopify domain
Order IDStringShopify order ID
Replacement ReasonStringOriginal order ID to created a replacement fort
Replacement ReasonStringThe 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 ReplacementsOptional BooleanWhether to check for previous replacements for the order customer. Default: true
Check Universal LimitsOptional BooleanWhether to check for domain wide number of replacements during last hour, 12 hours and 24 hours.
Default: true
Check Universal Amount LimitsOptional BooleanWhether to check amount refunded in the last 24 hours.
Linked to: Check Universal Limits.
Default: false
Check for Fraud LimitsOptional BooleanWhether to check for shipping/billing addresses and card details limits. Default: false
Send Notifications to DG Slack channelOptional BooleanWhether to send notifications to the DG Slack channel if the universal limits were exceeded.
Default: false
Billing AddressOptional ObjectShopify billing address object to overwrite the order address.
Default: order billing address
Shipping AddressOptional ObjectShopify shipping address object to overwrite the order address. Default: order shipping address
Shipping LinesOptional ListShopify shipping lines.
Default: order shipping lines with price set to zero
Line ItemsOptional ListShopify line items.
Default: order line items with variant id and quantity
Discount TypeOptional StringDiscount 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 CodesOptional ObjectList of shopify discounts for custom discount type
Update Order Note?Optional BooleanWhether to update the order note on the replacement order.
Default: true
Inventory BehaviourOptional StringInventory behaviour for the replacement order.
Default: Decrement Obeying Policy
Possible values: bypass, decrement_ignoring_policy, decrement_obeying_policy
Fraud Records LimitOptional NumberLimit for replacements created for address/card number/card name. Linked to: Check for Fraud Limits.
Default: 1
Fraud Addresses LimitOptional NumberLimit for replacements created from different addresses for a specific zip code.
Linked to: Check for Fraud Limits.
Default: 5
Hour LimitOptional NumberHour limit for replacements created.
Linked to: Check Universal Limits.
Default: 10
Twelve Hour LimitOptional NumberTwelve hour limit for replacements created.
Linked to: Check Universal Limits.
Default: 30
Twenty Four Hour LimitOptional NumberTwenty four hour limit for replacements created.
Linked to: Check Universal Limits.
Default: 50
Twenty Four Hour Amount LimitOptional NumberTwenty four hour amount limit for replacements created.
Linked to: Check Universal Amount Limits.
Default: 1000
Order Name PrefixOptional StringOrder name prix to append to the original order number in case it's provided
Use Safety StockOptional BoolenWhether 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

NameTypeDescription
Replacement Order CreatedBooleanWhether the replacement order was created
Order IDNumberReplacement order ID
Blocked by Safety ChecksBooleanWhether the replacement was blocked by safety/fraud checks
Replacement Note CreatedBooleanWhether the replacement note was created
Replacement Metafields CreatedBooleanWhether the replacement metafields were created
Replacement Metaobject CreatedBooleanWhether the replacement metaobject was created
Fraud Prevention Meta Objects CreatedBooleanWhether the fraud prevention addresses/card details meta objects were created
Replacement Meta Object UpdatedBooleanWhether the replacement meta object was updated after the order was created
Inventory Move SuccessfulBooleanWhether successfully moved the safety inventory to available after replacement order creation.
Linked to: Use Safety Stock
OrderObjectReplacement 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
        }
      }
    }
  }
}