价格规则 目的
价格规则是一组条件,包括适用对象和前提条件,必须遵守这些条件才能应用折扣代码。
所需的访问
read_price_rules 访问范围。
在本页面
连接数
discountCodes([PriceRuleDiscountCodeConnection!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulediscountcode))
价格规则的折扣代码列表。
| 争论 | 描述 | 
|---|---|
after() [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) | 
返回指定游标之后的元素。 | 
before() [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) | 
返回指定游标之前的元素。 | 
first() [Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01) | 
返回n列表中的第一个元素。 | 
last() [Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01) | 
返回n列表中的最后一个元素。 | 
query() [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) | 
支持的过滤器参数: + times_used有关使用过滤器的更多信息,请参见详细的搜索语法。  | 
reverse() [Boolean](https://shopify.dev/docs/admin-api/graphql/reference/scalar#boolean-2021-01) | 
颠倒基础列表的顺序。 默认值: false | 
savedSearchId() [ID](https://shopify.dev/docs/admin-api/graphql/reference/scalar#id-2021-01) | 
现有已保存搜索的ID。搜索的查询字符串用作查询参数。 | 
sortKey() [DiscountCodeSortKeys](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/discountcodesortkeys) | 
按给定键对基础列表进行排序。 默认值: ID | 
events([EventConnection!](https://shopify.dev/docs/admin-api/graphql/reference/events/eventconnection))
与价格规则关联的事件的分页列表。
| 争论 | 描述 | 
|---|---|
after() [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) | 
返回指定游标之后的元素。 | 
before() [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) | 
返回指定游标之前的元素。 | 
first() [Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01) | 
返回n列表中的第一个元素。 | 
last() [Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01) | 
返回n列表中的最后一个元素。 | 
query() [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) | 
支持的过滤器参数: + comments+ created_at+ subject_type+ verb有关使用过滤器的更多信息,请参见详细的搜索语法。  | 
reverse() [Boolean](https://shopify.dev/docs/admin-api/graphql/reference/scalar#boolean-2021-01) | 
颠倒基础列表的顺序。 默认值: false | 
sortKey() [EventSortKeys](https://shopify.dev/docs/admin-api/graphql/reference/events/eventsortkeys) | 
按给定键对基础列表进行排序。 默认值: ID | 
属性
- locationLimit(
[Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01))
可以将价格规则分配到订单的最大次数。 - allocationMethod(
[PriceRuleAllocationMethod!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleallocationmethod))
将价格规则的值分配给其已授权项目的方法。 - 应用程式(
[App](https://shopify.dev/docs/admin-api/graphql/reference/apps/app))
创建价格规则的应用程序。 - createdAt(
[DateTime!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#datetime-2021-01))
创建价格规则的日期和时间。 - customerSelection(
[PriceRuleCustomerSelection!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulecustomerselection))
可以使用此价格规则的客户。 - discountCodesCount(
[Int!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01))
与价格规则关联的折扣代码数量。 - endsAt(
[DateTime](https://shopify.dev/docs/admin-api/graphql/reference/scalar#datetime-2021-01))
价格规则结束的日期和时间。对于开放式价格规则,请使用null。 - 功能(
[[PriceRuleFeature!]!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulefeature))
价格规则功能列表。 - hasTimelineComment(
[Boolean!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#boolean-2021-01))
指示价格规则上是否有任何时间轴注释。 - 编号(
[ID!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#id-2021-01))
全局唯一标识符。 - itemEntitlements(
[PriceRuleItemEntitlements!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleitementitlements))
价格规则适用的项目。 - itemPrerequisites(
[PriceRuleLineItemPrerequisites!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulelineitemprerequisites))
价格规则适用的项目。 - legacyResourceId(
[UnsignedInt64!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#unsignedint64-2021-01))
REST Admin API中相应资源的ID。 - OncePerCustomer(
[Boolean!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#boolean-2021-01))
价格规则是否只能对每个客户应用一次。 - prerequisiteQuantityRange(
[PriceRuleQuantityRange](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulequantityrange))
要使用价格规则,已授权商品的数量必须在此范围内。 - prerequisiteShippingPriceRange(
[PriceRuleMoneyRange](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulemoneyrange))
运输价格必须落在此范围内,价格规则才能适用。 - prerequisiteSubtotalRange(
[PriceRuleMoneyRange](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulemoneyrange))
小标题价格的总和必须在该范围内,以适用价格规则。 - prerequisiteToEntitlementQuantityRatio(
[PriceRulePrerequisiteToEntitlementQuantityRatio](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleprerequisitetoentitlementquantityratio))
价格规则适用的先决条件项目的数量,与授权项目的数量相比。 - shareableUrls(
[[PriceRuleShareableUrl!]!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleshareableurl))
可用于共享折扣的URL。 - shippingEntitlements(
[PriceRuleShippingLineEntitlements!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleshippinglineentitlements))
价格规则适用的货运行。 - startsAt(
[DateTime!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#datetime-2021-01))
价格规则开始的日期和时间。 - status(
[PriceRuleStatus!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulestatus))
价格规则的状态。 - summary(
[String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01))
价格规则的详细摘要。 - target(
[PriceRuleTarget!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruletarget))
价格规则适用的行的类型(line_item或shipping_line)。 - title(
[String!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01))
价格规则的标题。 - totalSales(
[MoneyV2](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/moneyv2))
使用价格规则的订单的总销售额。 - usageCount(
[Int!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01))
使用价格规则的次数。该值是异步更新的,并且可以与实际使用次数不同。 - usageLimit(
[Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01))
可以总共使用价格规则的最大次数。 - validationPeriod(
[PriceRuleValidityPeriod!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulevalidityperiod))
价格规则适用的时间段。 - valueV2(
[PricingValue!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricingvalue))
价格规则的值。 
返回PriceRule的类型
[QueryRoot.priceRule](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/queryroot#pricerule-2021-01)[QueryRoot.priceRules](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/queryroot#pricerules-2021-01)
PriceRule的变异
- priceRuleActivate
激活价格规则。 - priceRuleCreate
使用输入创建价格规则。 - priceRuleDeactivate
停用价格规则。 - priceRuleDelete
删除价格规则。 - priceRuleUpdate
使用其ID和输入更新价格规则。 
实现
[CommentEventSubject](https://shopify.dev/docs/admin-api/graphql/reference/events/commenteventsubject)[HasEvents](https://shopify.dev/docs/admin-api/graphql/reference/events/hasevents)[LegacyInteroperability](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/legacyinteroperability)[Node](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/node)
弃用的栏位
显示隐藏
自动生成的类型,用于通过多个PriceRules分页。
在本页面
属性
- edges(
[[PriceRuleEdge!]!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerule))
边列表。 - pageInfo(
[PageInfo!](https://shopify.dev/docs/admin-api/graphql/reference/pageinfo))
有助于分页的信息。 
一种自动生成的类型,在分页期间保留一个PriceRule和一个光标。
在本页面
属性
- cursor(
[String!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01))
用于分页的光标。 - node(
[PriceRule!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerule))
PriceRuleEdge末尾的项目。 
返回PriceRuleEdge的类型
[PriceRuleConnection.edges](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerule#edges-2021-01)
