Skip to main content

Create pricing rules

Pricing rules are a set of configurations that determine the price of a delivery. You can set conditions and priority to a pricing rule so Delivery Gateway can automatically set the one you need during the order process. Read more about how pricing rules work: About pricing.

You can create and update pricing rules at any point with the API. Delivery Gateway will automatically use your pricing rules unless you directly specify prices during a session.

Create a pricing rule

Use the createPricing mutation to create a pricing rule. A "basic" pricing rule has only two requirements: a name and a price. Such a rule will match every possible condition and therefore will be available for all deliveries.

As always, the price field requires the amount and currency subfields.

mutation {
createPricing(
input: {
name: "Basic rule"
price: {
amount: 5,
currency: EUR
}
}
){
name
}
}

Add the condition field to specify possible conditions. The conditions are:

  • The delivery method.
  • The pricing zone: the country or countries the price applies to.
  • The delivery provider: different companies charge different prices.

For example, let's set a pricing rule for pickup point delivery in the United States by a provider called BestEx, applicable only to parcel lockers. We must disable this pricing rule for home delivery, specify the available pickup point types, and add the zone.

note

By default, there are no zones in the Delivery Gateway system: you need to create them and use the zone ID here.

mutation {
createPricing(
input: {
name: "Basic rule"
price: {
amount: 5,
currency: EUR
},
condition: {
isHomeDelivery: false,
isPickupPoint: true,
pickupPointTypes: LOCKER,
providers: GLS,
zoneId: "123"
}
}
){
name
}
}