younifyd
Menu

discountCodeAppUpdate

Updates a code discount, where the discount type is provided by an app extension that uses Shopify Functions.

Use it in a workflow

  1. Add a step and choose the Shopify connector.
  2. Pick the discountCodeAppUpdate action (under Discount).
  3. Fill in the fields below, then reference the result from later steps as {{discountcodeappupdate.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 DiscountCodeAppUpdate($id: ID!, $codeAppDiscount: DiscountCodeAppInput!) {
  discountCodeAppUpdate(id: $id, codeAppDiscount: $codeAppDiscount) {
    codeAppDiscount {
      appDiscountType {
        app
        appBridge
        appKey
        description
        discountClass
        discountClasses
        functionId
        targetType
        title
      }
      appliesOnOneTimePurchase
      appliesOnSubscription
      appliesOncePerCustomer
      asyncUsageCount
      codesCount {
        count
        precision
      }
      combinesWith {
        orderDiscounts
        productDiscounts
        productDiscountsWithTagsOnSameCartLine
        shippingDiscounts
      }
      context
      createdAt
      customerSelection
      discountClass
      discountClasses
      discountId
      endsAt
      errorHistory {
        errorsFirstOccurredAt
        firstOccurredAt
        hasBeenSharedSinceLastError
        hasSharedRecentErrors
      }
      hasTimelineComment
      recurringCycleLimit
      shareableUrls {
        targetItemImage
        targetType
        title
        url
      }
      startsAt
      status
      tags
      title
      totalSales {
        amount
        currencyCode
      }
      updatedAt
      usageLimit
    }
    userErrors {
      code
      extraInfo
      field
      message
    }
  }
}

Variables

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

idstringrequired

The ID of the discount to update.

codeAppDiscountobjectrequired

The input fields required to update the discount.

combinesWithobject4 fields
discountClassesarray<string>
titlestring
startsAtstring
endsAtstring
appliesOncePerCustomerboolean
codestring
customerSelectionobject3 fields
usageLimitnumber
contextobject4 fields
tagsarray<string>
functionIdstring
functionHandlestring
appliesOnSubscriptionboolean
appliesOnOneTimePurchaseboolean
recurringCycleLimitnumber
metafieldsarray<object>5 fields
json
{
  "id": "string",
  "codeAppDiscount": {
    "combinesWith": {
      "productDiscounts": false,
      "orderDiscounts": false,
      "shippingDiscounts": false,
      "productDiscountsWithTagsOnSameCartLine": {
        "add": "string",
        "remove": "string"
      }
    },
    "discountClasses": [
      "PRODUCT"
    ],
    "title": "string",
    "startsAt": "string",
    "endsAt": "string",
    "appliesOncePerCustomer": false,
    "code": "string",
    "customerSelection": {
      "all": false,
      "customers": {
        "add": "string",
        "remove": "string"
      },
      "customerSegments": {
        "add": "string",
        "remove": "string"
      }
    },
    "usageLimit": 0,
    "context": {
      "all": "ALL",
      "customers": {
        "add": "string",
        "remove": "string"
      },
      "customerSegments": {
        "add": "string",
        "remove": "string"
      },
      "markets": {
        "add": "string",
        "remove": "string"
      }
    },
    "tags": [
      "string"
    ],
    "functionId": "string"
  }
}

Response

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

codeAppDiscountobject
appDiscountTypeobject9 fields
appliesOnOneTimePurchaseboolean
appliesOnSubscriptionboolean
appliesOncePerCustomerboolean
asyncUsageCountnumber
codesCountobject2 fields
combinesWithobject4 fields
contextobject4 fields

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

createdAtstring
customerSelectionobject4 fields

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

discountClassstring

One ofPRODUCTORDERSHIPPING

discountClassesarray<object>
discountIdstring
endsAtstring
errorHistoryobject4 fields
hasTimelineCommentboolean
recurringCycleLimitnumber
shareableUrlsarray<object>
startsAtstring
statusstring

One ofACTIVEEXPIREDSCHEDULED

tagsarray<object>
titlestring
totalSalesobject2 fields
updatedAtstring
usageLimitnumber
userErrorsarray<object>
codeobject
extraInfoobject
fieldobject
messageobject

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

discountCodeAppUpdate — Shopify — Documentation