younifyd
Menu

returnCalculate

Calculates the financial outcome of a Return without creating it. Use this query to preview return costs before initiating the actual return process.

Use it in a workflow

  1. Add a step and choose the Shopify connector.
  2. Pick the returnCalculate action (under Return).
  3. Fill in the fields below, then reference the result from later steps as {{returncalculate.response.data}}.

Query

This is the query the action sends by default. Edit it in the step's Query field to change which fields come back.

graphql
query ReturnCalculate($input: CalculateReturnInput!) {
  returnCalculate(input: $input) {
    exchangeLineItems {
      calculatedDiscountAllocations {
        allocatedAmountSet
        discountApplication
      }
      discountedUnitPriceSet {
        presentmentMoney
        shopMoney
      }
      id
      originalUnitPriceSet {
        presentmentMoney
        shopMoney
      }
      quantity
      subtotalSet {
        presentmentMoney
        shopMoney
      }
      totalTaxSet {
        presentmentMoney
        shopMoney
      }
      variant {
        availableForSale
        availablePublicationsCount
        barcode
        compareAtPrice
        createdAt
        defaultCursor
        deliveryProfile
        displayName
        id
        inventoryItem
        inventoryPolicy
        inventoryQuantity
        legacyResourceId
        position
        price
        product
        publishedOnCurrentChannel
        publishedOnCurrentPublication
        requiresComponents
        selectedOptions
        sellableOnlineQuantity
        sellingPlanGroupCount
        sellingPlanGroupsCount
        showUnitPrice
        sku
        storefrontId
        taxCode
        taxable
        title
        unitPrice
        unitPriceMeasurement
        updatedAt
      }
    }
    id
    returnLineItems {
      fulfillmentLineItem {
        discountedTotal
        discountedTotalSet
        id
        lineItem
        originalTotal
        originalTotalSet
        quantity
      }
      id
      quantity
      restockingFee {
        amountSet
        id
        percentage
      }
      subtotalBeforeOrderDiscountsSet {
        presentmentMoney
        shopMoney
      }
      subtotalSet {
        presentmentMoney
        shopMoney
      }
      totalTaxSet {
        presentmentMoney
        shopMoney
      }
    }
    returnShippingFee {
      amountSet {
        presentmentMoney
        shopMoney
      }
      id
    }
  }
}

Variables

Pass these as a JSON object in the step's Variables field.

inputobjectrequired

The input fields for calculating a return.

orderIdstringrequired
returnLineItemsarray<object>3 fields
exchangeLineItemsarray<object>3 fields
returnShippingFeeobject1 fields
json
{
  "input": {
    "orderId": "string",
    "returnLineItems": [
      {
        "fulfillmentLineItemId": "string",
        "quantity": "string",
        "restockingFee": "string"
      }
    ],
    "exchangeLineItems": [
      {
        "quantity": "string",
        "variantId": "string",
        "appliedDiscount": "string"
      }
    ],
    "returnShippingFee": {
      "amount": {
        "amount": "string",
        "currencyCode": "string"
      }
    }
  }
}

Response

Read the result with {{returncalculate.response.data.data.returnCalculate}}. If the API returns errors, the step fails and they are at {{returncalculate.response.data.errors}}.

exchangeLineItemsarray<object>
calculatedDiscountAllocationsobject
discountedUnitPriceSetobject
idobject
originalUnitPriceSetobject
quantityobject
subtotalSetobject
totalTaxSetobject
variantobject
idstring
returnLineItemsarray<object>
fulfillmentLineItemobject
idobject
quantityobject
restockingFeeobject
subtotalBeforeOrderDiscountsSetobject
subtotalSetobject
totalTaxSetobject
returnShippingFeeobject
amountSetobject2 fields
idstring

Need more? See the Shopify guide for connection setup and behaviour shared by every action.