Skip to content

Instantly share code, notes, and snippets.

@deniszgonjanin
Created February 8, 2024 23:45
Show Gist options
  • Save deniszgonjanin/2b37a1fb011d43ef61065694da8565de to your computer and use it in GitHub Desktop.
Save deniszgonjanin/2b37a1fb011d43ef61065694da8565de to your computer and use it in GitHub Desktop.
Adding a removing products from Downpay purchase options

Programatically adding and removing products to Downpay purchase options

Using the Downpay API, you can add or remove products to purchase options with a single API call. For inputs, you will need:

  • The id of the purchase option in the app. You can find this ID by editing the relevant purchase option in the app - it is the last part of the URL of the edit page
  • The ids of the Shopify product(s) you'd like to add to the option.

The API is in GraphQL.

Adding a product to a purchase option:

The query:

mutation addProduct($input: PurchaseOptionGroupAddProductsInput!) {
  purchaseOptionGroupAddProducts(input: $input) {
    errors {
      field
      message
    }
    purchaseOptionGroupId
  }
}

The input variables:

{
  "input": {
    "id": "2591031514",
    "productIds": ["7907869130970", "1807928180974"]
  }
}

Removing a product from a purchase option

mutation removeProduct($input: PurchaseOptionGroupRemoveProductsInput!) {
  purchaseOptionGroupRemoveProducts(input: $input) {
    errors {
      field
      message
    }
    purchaseOptionGroupId
  }
}
{
  "input": {
    "id": "2591031514",
    "productIds": ["7907869130970", "1807928180974"]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment