Voog.com

Cart rules

Summary of cart rule endpoints

List all cart rules for the current site

Get list of cart rules.

GET /admin/api/ecommerce/v1/cart_rules

Example response:

Status: 200 OK
[
  {
    "id": 1,
    "enabled": true,
    "position": 1,
    "kind": "shipping_cost",
    "target_id": 1,
    "target_kind": "shipping_method",
    "conditions": [
      {
        "value": "10.0",
        "comparator": ">",
        "field": "items_subtotal_amount",
        "value_type": "decimal"
      }
    ],
    "result": {
      "value": "1.0",
      "field": "shipping_subtotal_amount",
      "value_type": "decimal"
    },
    "valid_from": null,
    "valid_to": null,
    "created_at": "2020-05-26T09:34:40.000Z",
    "updated_at": "2020-05-26T09:34:40.000Z"    
  }
]

Filter attributes

Read more about filters.

  • Object cart_rule attributes: id, enabled, kind, target_id, target_kind, valid_from, valid_to, created_at, updated_at.

List attributes of a cart_rule

GET /admin/api/ecommerce/v1/cart_rules/1

Example request:

GET http://helloworld.voog.com/admin/api/ecommerce/v1/cart_rules/1

Example response:

Status: 200 OK
{
  "id": 1,
  "enabled": true,
  "position": 1,
  "kind": "shipping_cost",
  "target_id": 1,
  "target_kind": "shipping_method",
  "conditions": [
    {
      "value": "10.0",
      "comparator": ">",
      "field": "items_subtotal_amount",
      "value_type": "decimal"
    }
  ],
  "result": {
    "value": "1.0",
    "field": "shipping_subtotal_amount",
    "value_type": "decimal"
  },
  "valid_from": null,
  "valid_to": null,
  "created_at": "2020-05-26T09:34:40.000Z",
  "updated_at": "2020-05-26T09:34:40.000Z"    
}

Create a new cart_rule for the current site

POST /admin/api/ecommerce/v1/cart_rules

Example data:

{
  "kind": "shipping_cost",
  "target_id": 1,
  "target_kind": "shipping_method",
  "conditions": [
    {
      "value": "10.0",
      "comparator": ">",
      "field": "items_subtotal_amount",
      "value_type": "decimal"
    }
  ],
  "result": {
    "value": "1.0",
    "field": "shipping_subtotal_amount",
    "value_type": "decimal"
  }
}

Example response:

Status: 201 Created
{
  "id": 1,
  "enabled": true,
  "position": 1,
  "kind": "shipping_cost",
  "target_id": 1,
  "target_kind": "shipping_method",
  "conditions": [
    {
      "value": "10.0",
      "comparator": ">",
      "field": "items_subtotal_amount",
      "value_type": "decimal"
    }
  ],
  "result": {
    "value": "1.0",
    "field": "shipping_subtotal_amount",
    "value_type": "decimal"
  },
  "valid_from": null,
  "valid_to": null,
  "created_at": "2020-05-26T09:34:40.000Z",
  "updated_at": "2020-05-26T09:34:40.000Z"      
}

Parameters

  • enabled — Flag switching the cart rule on or off, true by default.
  • position - An integer determining the cart rule's execution order.
  • kind - Cart rule type, currently only shipping_cost is supported.
  • target_id - Rule target ID.
  • target_kind - Rule target type, currently only shipping_method is supported.
  • conditions - An array of objects with the following fields. Note that all conditions must match for the rule to take effect.
    • field - Name of the cart field to compare against value.
    • comparator - Comparison operator, one of <, <=, ==, >=, >.
    • value - Comparison value.
    • value_type - Comparison value type, currently only decimal is supported.
  • result - An array of objects with the following fields:
    • field - Name of the cart field to modify.
    • value - Override value.
    • value_type - Override value type, currently only decimal is supported.
  • valid_from - Currenty unsupported.
  • valid_to - Currenty unsupported.

Update attributes of a cart_rule

PUT /admin/api/ecommerce/v1/cart_rules/1

This request updates the cart rule with the provided attributes.

Example request:

PUT http://helloworld.voog.com/admin/api/ecommerce/v1/cart_rules/1

Example data:

{
  "kind": "shipping_cost",
  "target_id": 1,
  "target_kind": "shipping_method",
  "conditions": [
    {
      "value": "10.0",
      "comparator": ">",
      "field": "items_subtotal_amount",
      "value_type": "decimal"
    }
  ],
  "result": {
    "value": "1.0",
    "field": "shipping_subtotal_amount",
    "value_type": "decimal"
  }
}

Example response:

Status: 200 OK
{
  "id": 1,
  "enabled": true,
  "position": 1,
  "kind": "shipping_cost",
  "target_id": 1,
  "target_kind": "shipping_method",
  "conditions": [
    {
      "value": "10.0",
      "comparator": ">",
      "field": "items_subtotal_amount",
      "value_type": "decimal"
    }
  ],
  "result": {
    "value": "1.0",
    "field": "shipping_subtotal_amount",
    "value_type": "decimal"
  },
  "valid_from": null,
  "valid_to": null,
  "created_at": "2020-05-26T09:34:40.000Z",
  "updated_at": "2020-05-26T09:34:40.000Z"
}

Parameters

  • enabled — Flag switching the cart rule on or off, true by default.
  • position - An integer determining the cart rule's execution order.
  • kind - Cart rule type, currently only shipping_cost is supported.
  • target_id - Rule target ID.
  • target_kind - Rule target type, currently only shipping_method is supported.
  • conditions - An array of objects with the following fields. Note that all conditions must match for the rule to take effect.
    • field - Name of the cart field to compare against value.
    • comparator - Comparison operator, one of <, <=, ==, >=, >.
    • value - Comparison value.
    • value_type - Comparison value type, currently only decimal is supported.
  • result - An array of objects with the following fields:
    • field - Name of the cart field to modify.
    • value - Override value.
    • value_type - Override value type, currently only decimal is supported.
  • valid_from - Currenty unsupported.
  • valid_to - Currenty unsupported.

Remove a cart_rule

DELETE /admin/api/ecommerce/v1/cart_rules/1

This request deletes the given cart_rule.

Example request:

DELETE http://helloworld.voog.com/admin/api/ecommerce/v1/cart_rules/1

Example response:

Status: 204 No Content