Price Rules Mutations

CreatePriceRule

Creates a new price rule.

Parameters:

ParameterTypeDescription
inputPriceRuleInput!Price rule data.

Example Query:

mutation CreatePriceRule($input: PriceRuleInput!) {
  CreatePriceRule(input: $input) {
    id
    label
    active
  }
}

Example Variables:

{
  "input": {
    "label": "Summer Discount",
    "active": true,
    "selection_type": "all_products",
    "price_type": "calculated",
    "base_price": "unit_cost",
    "operator": "multiply",
    "value": 1.2
  }
}

UpdatePriceRule

Updates an existing price rule.

Parameters:

ParameterTypeDescription
idInt!ID of the price rule.
inputPriceRuleInput!Updated data.

Example Query:

mutation UpdatePriceRule($id: Int!, $input: PriceRuleInput!) {
  UpdatePriceRule(id: $id, input: $input) {
    id
    label
  }
}

DeletePriceRule

Deletes a price rule.

Parameters:

ParameterTypeDescription
idInt!ID of the price rule to delete.

DisablePriceRule

Deactivates a price rule.

Parameters:

ParameterTypeDescription
idInt!ID of the price rule to disable.

EnablePriceRule

Re-activates a previously disabled price rule.

Parameters:

ParameterTypeDescription
idInt!ID of the price rule to enable.

Input Data Types

PriceRuleInput

FieldTypeDescription
idIntID.
labelStringName of the rule.
activeBooleanTrue if the rule is activated.
selection_typeSelectionTypeDefines target scope.
price_level_idIntTarget PriceLevel ID.
price_typePriceTypeSet directly or dynamically calculated.
base_priceBasePriceUsed if price type is calculated.
base_price_price_levelPriceLevelInputTarget for the calculation.
operatorOperatorCalculation type.
valueFloatConstant to pair with the operator.
roundIntPrecision value.
start_date_conditionDateActive from date.
end_date_conditionDateActive until date.
currency_conditionCurrencyInputCurrency mapping filter.
variants[VariantInput]Selected variants.
attributes[AttributeInput]Selected attributes.
product_tags[ProductTagInput]Selected product tags.
seasons_condition[SeasonInput]Active seasons.
locations_condition[LocationInput]Applicable locations.
customer_tags_condition[CustomerTagInput]Applicable customer tags.

Enums

SelectionType

ValueDescription
all_productsApplies to all products.
selected_attributesApplies to exact attributes.
selected_tagsApplies to specific product tags.
selected_variantsApplies to exactly selected variants.

PriceType

ValueDescription
setFixed price amount.
calculatedDynamic calculation based on rules.

Operator

ValueDescription
addBase Price + Value.
multiplyBase Price * Value.
minusBase Price - Value.

BasePrice

ValueDescription
unit_costCalculated from product unit cost.
last_purchased_priceCalculated from the last purchase price.
price_levelCalculated from another price level.