younifyd
Menu

discountAutomaticAppCreate

Creates an automatic discount that's managed by an app. Use this mutation with Shopify Functions when you need advanced, custom, or dynamic discount capabilities that aren't supported by Shopify's native discount types.

Use it in a workflow

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

Query

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

graphql
mutation DiscountAutomaticAppCreate($automaticAppDiscount: DiscountAutomaticAppInput!) {
  discountAutomaticAppCreate(automaticAppDiscount: $automaticAppDiscount) {
    automaticAppDiscount {
      appDiscountType {
        app
        appBridge
        appKey
        description
        discountClass
        discountClasses
        functionId
        targetType
        title
      }
      appliesOnOneTimePurchase
      appliesOnSubscription
      asyncUsageCount
      combinesWith {
        orderDiscounts
        productDiscounts
        productDiscountsWithTagsOnSameCartLine
        shippingDiscounts
      }
      context
      createdAt
      discountClass
      discountClasses
      discountId
      endsAt
      errorHistory {
        errorsFirstOccurredAt
        firstOccurredAt
        hasBeenSharedSinceLastError
        hasSharedRecentErrors
      }
      recurringCycleLimit
      startsAt
      status
      tags
      title
      updatedAt
    }
    userErrors {
      code
      extraInfo
      field
      message
    }
  }
}

Variables

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

automaticAppDiscountobjectrequired

The input data used to create the automatic discount.

combinesWithobject4 fields
discountClassesarray<string>
titlestring
startsAtstring
endsAtstring
contextobject4 fields
tagsarray<string>
functionIdstring
functionHandlestring
metafieldsarray<object>5 fields
appliesOnSubscriptionboolean
appliesOnOneTimePurchaseboolean
recurringCycleLimitnumber
json
{
  "automaticAppDiscount": {
    "combinesWith": {
      "productDiscounts": false,
      "orderDiscounts": false,
      "shippingDiscounts": false,
      "productDiscountsWithTagsOnSameCartLine": {
        "add": "string",
        "remove": "string"
      }
    },
    "discountClasses": [
      "PRODUCT"
    ],
    "title": "string",
    "startsAt": "string",
    "endsAt": "string",
    "context": {
      "all": "ALL",
      "customers": {
        "add": "string",
        "remove": "string"
      },
      "customerSegments": {
        "add": "string",
        "remove": "string"
      },
      "markets": {
        "add": "string",
        "remove": "string"
      }
    },
    "tags": [
      "string"
    ],
    "functionId": "string",
    "functionHandle": "string",
    "metafields": [
      {
        "id": "string",
        "namespace": "string",
        "key": "string",
        "value": "string",
        "type": "string"
      }
    ],
    "appliesOnSubscription": false,
    "appliesOnOneTimePurchase": false
  }
}

Response

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

automaticAppDiscountobject
appDiscountTypeobject9 fields
appliesOnOneTimePurchaseboolean
appliesOnSubscriptionboolean
asyncUsageCountnumber
combinesWithobject4 fields
contextobject4 fields

This field can return one of several different object shapes — properties from every possible shape are shown together.

createdAtstring
discountClassstring

One ofPRODUCTORDERSHIPPING

discountClassesarray<object>
discountIdstring
endsAtstring
errorHistoryobject4 fields
recurringCycleLimitnumber
startsAtstring
statusstring

One ofACTIVEEXPIREDSCHEDULED

tagsarray<object>
titlestring
updatedAtstring
userErrorsarray<object>
codeobject
extraInfoobject
fieldobject
messageobject

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