latestSwagger 2.0ShopBase Dev 1.02026-08-10153268547.4 KB

353ccde6240d

PriceRule

Creates a price rule

Creates a price rule

post/admin/price_rules.json

Request body

allocation_limitinteger
allocation_methodstring

The allocation method of the price rule. Valid values:

  • each: The discount is applied to each of the entitled items. For example, for a price rule that takes $15 off, each entitled line item in a checkout will be discounted by $15.
  • across: The calculated discount amount will be applied across the entitled items. For example, for a price rule that takes $15 off, the discount will be applied across all the entitled items. When the value of target_type is shipping_line, then this value must be each.
created_atstring

The date and time (ISO 8601 format) when the price rule was created.

customer_selectionstring

The customer selection for the price rule. Valid values:

  • all: The price rule is valid for all customers.
  • prerequisite: The customer must either belong to one of the customer saved searches specified by prerequisite_saved_search_ids , or be one of the customers specified by prerequisite_customer_ids.
ends_atstring

The date and time (ISO 8601 format) when the price rule ends. Must be after starts_at.

entitled_collection_idsinteger[]

A list of IDs of collections whose products will be eligible to the discount. It can be used only with target_type set to line_item and target_selection set to entitled. It can't be used in combination with entitled_product_ids or entitled_variant_ids.

entitled_country_idsinteger[]

A list of IDs of shipping countries that will be entitled to the discount. It can be used only with target_type set to shipping_line and target_selection set to entitled.

entitled_product_idsinteger[]

A list of IDs of products that will be entitled to the discount. It can be used only with target_type set to line_item and target_selection set to entitled. If a product variant is included in entitled_variant_ids, then entitled_product_ids can't include the ID of the product associated with that variant.

entitled_variant_idsinteger[]

A list of IDs of product variants that will be entitled to the discount. It can be used only with target_type set to line_item and target_selection set to entitled.

idinteger

The ID for the price rule.

maximum_discount_amountnumber

maximum discount use

once_per_customerboolean

Whether the generated discount code will be valid only for a single use per customer. This is tracked using customer ID.

prerequisite_collection_idsinteger[]

List of collection ids that will be a prerequisites for a Buy X Get Y discount. The entitled_collection_ids can be used only with:

  • target_type set to line_item,
  • target_selection set to entitled,
  • allocation_method set to each and
  • prerequisite_to_entitlement_quantity_ratio defined. Cannot be used in combination with prerequisite_product_ids or prerequisite_variant_ids.
prerequisite_customer_idsinteger[]

List of variant ids that will be a prerequisites for a Buy X Get Y type discount. The entitled_variant_ids can be used only with:

  • target_type set to line_item,
  • target_selection set to entitled,
  • allocation_method set to each and
  • prerequisite_to_entitlement_quantity_ratio defined.
prerequisite_emailsstring[]

List of emails that will be a prerequisite for a discount

prerequisite_product_idsinteger[]

List of product ids that will be a prerequisites for a Buy X Get Y type discount. The prerequisite_product_ids can be used only with:

  • target_type set to line_item,
  • target_selection set to entitled,
  • allocation_method set to each and
  • prerequisite_to_entitlement_quantity_ratio defined.
prerequisite_variant_idsinteger[]

List of variant ids that will be a prerequisites for a Buy X Get Y type discount. The entitled_variant_ids can be used only with:

  • target_type set to line_item,
  • target_selection set to entitled,
  • allocation_method set to each and
  • prerequisite_to_entitlement_quantity_ratio defined.
quota_per_customerinteger

Limit use a customer

quota_per_storeinteger

Limit use a store

shop_idinteger
starts_atstring

The date and time (ISO 8601 format) when the price rule starts.

statusstring
target_selectionstring

The target selection method of the price rule. Valid values:

  • all: The price rule applies the discount to all line items in the checkout.
  • entitled: The price rule applies the discount to selected entitlements only.
target_typestring

The target type that the price rule applies to. Valid values:

  • line_item: The price rule applies to the cart's line items.
  • shipping_line: The price rule applies to the cart's shipping lines.
titlestring

The title of the price rule. This is used by the ShopBase admin search to retrieve discounts. It is also displayed on the Discounts page of the ShopBase admin for bulk discounts. For non-bulk discounts, the discount code is displayed on the admin. For a consistent search experience, use the same value for title as the code property of the associated discount code.

total_redemptioninteger

Total amount used discount

total_sale_countnumber

Total discount sale count

typestring
updated_atstring

The date and time (ISO 8601 format) when the price rule was updated.

usage_countinteger
usage_limitinteger

The maximum number of times the price rule can be used, per discount code.

valuenumber

The value of the price rule. If if the value of target_type is shipping_line, then only -100 is accepted. The value must be negative.

value_typestring

The value type of the price rule. Valid values:

  • fixed_amount: Applies a discount of value as a unit of the store's currency. For example, if value is -30 and the store's currency is USD, then $30 USD is deducted when the discount is applied.
  • percentage: Applies a percentage discount of value. For example, if value is -30, then 30% will be deducted when the discount is applied. If target_type is shipping_line, then only percentage is accepted.

Example request

{
  "created_at": "2019-03-14T16:09:54-04:00",
  "customer_selection": "prerequisite",
  "ends_at": "2019-07-19T17:59:10Z",
  "entitled_collection_ids": [
    4564654869,
    8979761006
  ],
  "entitled_country_ids": [
    6798798798,
    5675765905
  ],
  "entitled_product_ids": [
    7897397755,
    42382368242
  ],
  "id": 9808080986,
  "once_per_customer": true,
  "prerequisite_collection_ids": [
    384028349005,
    3492039843
  ],
  "prerequisite_customer_ids": [
    384028349005,
    3492039843
  ],
  "prerequisite_emails": [
    "hoaipiu@gmail.com",
    "tieumapmap@gmail.com",
    "traxanh@mtp.com"
  ],
  "prerequisite_quantity_range": {
    "greater_than_or_equal_to": 50
  },
  "prerequisite_shipping_price_range": {
    "less_than_or_equal_to": 10
  },
  "prerequisite_subtotal_range": {
    "greater_than_or_equal_to": 40
  },
  "prerequisite_variant_ids": [
    384028349005,
    3492039843
  ],
  "starts_at": "2019-04-19T17:59:10Z",
  "target_selection": "entitled",
  "target_type": "line_item",
  "title": "SUMMERSALE10OFF",
  "updated_at": "2019-03-14T16:09:54-04:00",
  "usage_limit": 10,
  "value": -60,
  "value_type": "fixed_amount"
}

Response

OK

Example response

{
  "price_rule": {
    "created_at": "2019-03-14T16:09:54-04:00",
    "customer_selection": "prerequisite",
    "ends_at": "2019-07-19T17:59:10Z",
    "entitled_collection_ids": [
      4564654869,
      8979761006
    ],
    "entitled_country_ids": [
      6798798798,
      5675765905
    ],
    "entitled_product_ids": [
      7897397755,
      42382368242
    ],
    "id": 9808080986,
    "once_per_customer": true,
    "prerequisite_collection_ids": [
      384028349005,
      3492039843
    ],
    "prerequisite_customer_ids": [
      384028349005,
      3492039843
    ],
    "prerequisite_emails": [
      "hoaipiu@gmail.com",
      "tieumapmap@gmail.com",
      "traxanh@mtp.com"
    ],
    "prerequisite_quantity_range": {
      "greater_than_or_equal_to": 50
    },
    "prerequisite_shipping_price_range": {
      "less_than_or_equal_to": 10
    },
    "prerequisite_subtotal_range": {
      "greater_than_or_equal_to": 40
    },
    "prerequisite_variant_ids": [
      384028349005,
      3492039843
    ],
    "starts_at": "2019-04-19T17:59:10Z",
    "target_selection": "entitled",
    "target_type": "line_item",
    "title": "SUMMERSALE10OFF",
    "updated_at": "2019-03-14T16:09:54-04:00",
    "usage_limit": 10,
    "value": -60,
    "value_type": "fixed_amount"
  }
}