younifyd
Menu

cartCreate

Create a cart, optionally with line items, buyer identity, discount codes, gift cards and attributes; returns the cart and its `checkoutUrl`.

Use it in a workflow

  1. Add a step and choose the Shopify Storefront connector.
  2. Pick the cartCreate action (under Cart).
  3. Fill in the fields below, then reference the result from later steps as {{cartcreate.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 CartCreate($input: CartInput) {
  cartCreate(input: $input) {
    cart {
      appliedGiftCards {
        amountUsed
        amountUsedV2
        balance
        balanceV2
        id
        lastCharacters
        presentmentAmountUsed
      }
      attributes {
        key
        value
      }
      buyerIdentity {
        countryCode
        customer
        deliveryAddressPreferences
        email
        phone
        preferences
        purchasingCompany
      }
      checkoutUrl
      cost {
        checkoutChargeAmount
        subtotalAmount
        subtotalAmountEstimated
        totalAmount
        totalAmountEstimated
        totalDutyAmount
        totalDutyAmountEstimated
        totalTaxAmount
        totalTaxAmountEstimated
      }
      createdAt
      delivery
      discountAllocations {
        discountApplication
        discountedAmount
        sourceDiscountApplication
        targetType
      }
      discountApplications {
        allocationMethod
        targetSelection
        targetType
        totalAllocatedAmount
        value
      }
      discountCodes {
        applicable
        code
      }
      estimatedCost {
        checkoutChargeAmount
        subtotalAmount
        totalAmount
        totalDutyAmount
        totalTaxAmount
      }
      id
      note
      totalQuantity
      updatedAt
    }
    userErrors {
      code
      field
      message
    }
    warnings {
      code
      message
      target
    }
  }
}

Variables

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

inputobject

The fields used to create a cart.

attributesarray<object>2 fields
linesarray<object>5 fields
discountCodesarray<string>
giftCardCodesarray<string>
notestring
buyerIdentityobject7 fields
deliveryobject1 fields
metafieldsarray<object>3 fields
sourceNamestring
json
{
  "input": {
    "attributes": [
      {
        "key": "string",
        "value": "string"
      }
    ],
    "lines": [
      {
        "merchandiseId": "string",
        "attributes": "string",
        "quantity": "string",
        "sellingPlanId": "string",
        "parent": "string"
      }
    ],
    "discountCodes": [
      "string"
    ],
    "giftCardCodes": [
      "string"
    ],
    "note": "string",
    "buyerIdentity": {
      "email": "string",
      "phone": "string",
      "companyLocationId": "string",
      "countryCode": "AF",
      "customerAccessToken": "string",
      "deliveryAddressPreferences": [
        "string"
      ],
      "preferences": {
        "delivery": "string",
        "wallet": "string"
      }
    },
    "delivery": {
      "addresses": [
        "string"
      ]
    },
    "metafields": [
      {
        "key": "string",
        "value": "string",
        "type": "string"
      }
    ],
    "sourceName": "string"
  }
}

Response

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

cartobject
appliedGiftCardsarray<object>
attributesarray<object>
buyerIdentityobject7 fields
checkoutUrlstring
costobject9 fields
createdAtstring
deliveryobject
discountAllocationsarray<object>
discountApplicationsarray<object>
discountCodesarray<object>
estimatedCostobject5 fields
idstring
notestring
totalQuantitynumber
updatedAtstring
userErrorsarray<object>
codeobject
fieldobject
messageobject
warningsarray<object>
codeobject
messageobject
targetobject

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