collection Rules Conditionsquery
query
2024-10latest
Lists all rules that can be used to create smart collections.
CollectionRuleConditions possible returns
This object defines all columns and allowed relations that can be used in rules for smart collections to automatically include the matching products.
Was this section helpful?
Code examples for QUERY: collectionRulesConditions
Query Reference for QUERY: collectionRulesConditions
"{\n collectionRulesConditions {\n # CollectionRuleConditions fields\n }\n}"
Input Reference for QUERY: collectionRulesConditions
Schema Reference for QUERY: collectionRulesConditions
Display Examples for QUERY: collectionRulesConditions
[ { "example": { "type_name": "collectionrulesconditions", "title": "Retrieve a list of collection rule conditions", "query_string": "query {\n collectionRulesConditions {\n ruleType\n allowedRelations\n defaultRelation\n }\n}", "response": { "data": { "collectionRulesConditions": [ { "ruleType": "TITLE", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "NOT_CONTAINS" ], "defaultRelation": "CONTAINS" }, { "ruleType": "VARIANT_TITLE", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "NOT_CONTAINS" ], "defaultRelation": "CONTAINS" }, { "ruleType": "TYPE", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "NOT_CONTAINS" ], "defaultRelation": "EQUALS" }, { "ruleType": "PRODUCT_TAXONOMY_NODE_ID", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS" }, { "ruleType": "VENDOR", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "NOT_CONTAINS" ], "defaultRelation": "EQUALS" }, { "ruleType": "IS_PRICE_REDUCED", "allowedRelations": [ "IS_SET", "IS_NOT_SET" ], "defaultRelation": "IS_SET" }, { "ruleType": "VARIANT_PRICE", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN" }, { "ruleType": "VARIANT_COMPARE_AT_PRICE", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN" }, { "ruleType": "VARIANT_INVENTORY", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN" }, { "ruleType": "VARIANT_WEIGHT", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN" }, { "ruleType": "TAG", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS" }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN" }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS" }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN" }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN" }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS" }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS" }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS" }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN" }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS" }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN" }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS" }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS" }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS" } ] } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/merchandising/test/unit/graph_api/admin/collection_rule_conditions_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { collectionRulesConditions { ruleType allowedRelations defaultRelation } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n collectionRulesConditions {\n ruleType\n allowedRelations\n defaultRelation\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n collectionRulesConditions {\n ruleType\n allowedRelations\n defaultRelation\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n collectionRulesConditions {\n ruleType\n allowedRelations\n defaultRelation\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n collectionRulesConditions {\n ruleType\n allowedRelations\n defaultRelation\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [] }, { "example": { "type_name": "collectionrulesconditions", "title": "Retrieve a list of collection rule conditions along with metafield rule objects", "description": "Retrieves a list of collection rule conditions along with the rule object fields.\nEach returned rule object is a `CollectionRuleMetafieldCondition` that contains the metafield definition it refers to.\nSee an example on how to create an automated collection with metafield definition collection rules on the `collectionCreate` mutation.\n", "query_string": "query {\n collectionRulesConditions {\n ruleType\n allowedRelations\n defaultRelation\n ruleObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n ownerType\n type {\n name\n }\n validations {\n value\n }\n }\n }\n }\n }\n}", "response": { "data": { "collectionRulesConditions": [ { "ruleType": "TITLE", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "NOT_CONTAINS" ], "defaultRelation": "CONTAINS", "ruleObject": null }, { "ruleType": "VARIANT_TITLE", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "NOT_CONTAINS" ], "defaultRelation": "CONTAINS", "ruleObject": null }, { "ruleType": "TYPE", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "NOT_CONTAINS" ], "defaultRelation": "EQUALS", "ruleObject": null }, { "ruleType": "PRODUCT_TAXONOMY_NODE_ID", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS", "ruleObject": null }, { "ruleType": "VENDOR", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "NOT_CONTAINS" ], "defaultRelation": "EQUALS", "ruleObject": null }, { "ruleType": "IS_PRICE_REDUCED", "allowedRelations": [ "IS_SET", "IS_NOT_SET" ], "defaultRelation": "IS_SET", "ruleObject": null }, { "ruleType": "VARIANT_PRICE", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN", "ruleObject": null }, { "ruleType": "VARIANT_COMPARE_AT_PRICE", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN", "ruleObject": null }, { "ruleType": "VARIANT_INVENTORY", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN", "ruleObject": null }, { "ruleType": "VARIANT_WEIGHT", "allowedRelations": [ "EQUALS", "NOT_EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN", "ruleObject": null }, { "ruleType": "TAG", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS", "ruleObject": null }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/89321433", "name": "Non-standard rating", "ownerType": "PRODUCT", "type": { "name": "rating" }, "validations": [ { "value": "1.0" }, { "value": "6.0" } ] } } }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/371357715", "name": "model", "ownerType": "PRODUCT", "type": { "name": "single_line_text_field" }, "validations": [ { "value": "9" } ] } } }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/397285273", "name": "Competitor cost", "ownerType": "PRODUCT", "type": { "name": "number_decimal" }, "validations": [] } } }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/475536288", "name": "Year released", "ownerType": "PRODUCT", "type": { "name": "number_integer" }, "validations": [] } } }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/660917123", "name": "Materials", "ownerType": "PRODUCT", "type": { "name": "list.single_line_text_field" }, "validations": [] } } }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/804905764", "name": "Recyclable", "ownerType": "PRODUCT", "type": { "name": "boolean" }, "validations": [] } } }, { "ruleType": "PRODUCT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/985769189", "name": "Exporters", "ownerType": "PRODUCT", "type": { "name": "list.single_line_text_field" }, "validations": [] } } }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/180578340", "name": "competitor cost", "ownerType": "PRODUCTVARIANT", "type": { "name": "number_decimal" }, "validations": [] } } }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/406572501", "name": "Contents", "ownerType": "PRODUCTVARIANT", "type": { "name": "list.single_line_text_field" }, "validations": [] } } }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS", "GREATER_THAN", "LESS_THAN" ], "defaultRelation": "GREATER_THAN", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/685760035", "name": "size of the item", "ownerType": "PRODUCTVARIANT", "type": { "name": "number_integer" }, "validations": [] } } }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/898504968", "name": "Recyclable", "ownerType": "PRODUCTVARIANT", "type": { "name": "boolean" }, "validations": [] } } }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/1043030858", "name": "available", "ownerType": "PRODUCTVARIANT", "type": { "name": "single_line_text_field" }, "validations": [] } } }, { "ruleType": "VARIANT_METAFIELD_DEFINITION", "allowedRelations": [ "EQUALS" ], "defaultRelation": "EQUALS", "ruleObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/1067782171", "name": "Exporters", "ownerType": "PRODUCTVARIANT", "type": { "name": "list.single_line_text_field" }, "validations": [] } } } ] } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/merchandising/test/unit/graph_api/admin/collection_rule_conditions_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { collectionRulesConditions { ruleType allowedRelations defaultRelation ruleObject { ... on CollectionRuleMetafieldCondition { metafieldDefinition { id name ownerType type { name } validations { value } } } } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n collectionRulesConditions {\n ruleType\n allowedRelations\n defaultRelation\n ruleObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n ownerType\n type {\n name\n }\n validations {\n value\n }\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n collectionRulesConditions {\n ruleType\n allowedRelations\n defaultRelation\n ruleObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n ownerType\n type {\n name\n }\n validations {\n value\n }\n }\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n collectionRulesConditions {\n ruleType\n allowedRelations\n defaultRelation\n ruleObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n ownerType\n type {\n name\n }\n validations {\n value\n }\n }\n }\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n collectionRulesConditions {\n ruleType\n allowedRelations\n defaultRelation\n ruleObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n ownerType\n type {\n name\n }\n validations {\n value\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [] } ]