Developers

Shipping methods

Summary of shipping method endpoints

All endpoints except DELETE take optional query parameters that enhance the response objects:

  • include — enhance the response objects. The supported value is:
    • translations — includes translations for all translatable objects and keys.
    • cart_rules — includes all associated cart rules.
  • language_code — display all top-level values in the given language context.

List all available shipping methods for the current site

Get list of shipping methods for current site.

This endpoint also allows anonymous access.

GET /admin/api/ecommerce/v1/shipping_methods?include=translations

Example response:

Status: 200 OK
[
  {
    "id": 1,
    "name": "Basic shipping",
    "amount": "10.0",
    "description": "Basic shipping without secondary options",
    "enabled": true,
    "created_at": "2016-12-05T14:57:52.000Z",
    "updated_at": "2017-03-30T11:48:07.000Z",
    "tax_rate": null,
    "options": [],
    "translations": {
      "name": {
        "en": "Basic shipping", 
        "et": "Tavatarne"
      },
      "description": {
        "en": "Basic shipping without secondary options", 
        "et": "Tavatarne ilma valikuteta"
      }
    },    
  }, {
    "id": 2,
    "name": "Advanced shipping",
    "amount": "24.0",
    "description": "Advanced shipping with multiple options",
    "enabled": true,
    "created_at": "2016-12-05T14:57:52.000Z",
    "updated_at": "2017-03-30T11:48:07.000Z",
    "tax_rate": null,
    "options": [
      "option 1",
      "option 2"
    ],
    "translations": {
      "name": {
        "en": "Advanced shipping", 
        "et": "Eritarne"
      },
      "description": {
        "en": "Advanced shipping with multiple options", 
        "et": "Eritarne alamvalikutega"
      }      
    },        
  }
]

Create a new shipping method for the current site

POST /admin/api/ecommerce/v1/shipping_methods?include=translations

Example data:

{
  "name": "New shipping method",
  "amount": "15.0",
  "enabled": true,
  "translations": {
    "name": {
      "en": "New shipping method", 
      "et": "Uus tarneviis"
    },
    "description": {
      "en": "Description of new shipping method", 
      "et": "Uue tarneviisi kirjeldus"
    }    
  }     
}

Example response:

Status: 201 Created
{
  "id": 3,
  "name": "New shipping method",
  "amount": "15.0",
  "description": "",
  "enabled": true,
  "created_at": "2017-03-30T11:48:07.000Z",
  "updated_at": "2017-03-30T11:48:07.000Z",
  "tax_rate": null,
  "options": [],
  "translations": {
    "name": {
      "en": "New shipping method", 
      "et": "Uus tarneviis"
    },
    "description": {
      "en": "Description of new shipping method", 
      "et": "Uue tarneviisi kirjeldus"
    }    
  }  
}

Get data for a single shipping method

GET /admin/api/ecommerce/v1/shipping_methods/1?include=translations

This endpoint also allows anonymous access.

Example request:

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

Example response:

Status: 200 OK
{
  "id": 1,
  "name": "Basic shipping",
  "amount": "10.0",
  "description": "Basic shipping without secondary options",
  "enabled": true,
  "created_at": "2016-12-05T14:57:52.000Z",
  "updated_at": "2017-03-30T11:48:07.000Z",
  "tax_rate": null,
  "options": [],
  "translations": {
    "name": {
      "en": "Basic shipping", 
      "et": "Tavatarne"
    },
    "description": {
      "en": "Basic shipping without secondary options", 
      "et": "Tavatarne ilma valikuteta"
    }    
  }  
}

Update attributes of a single shipping method

PUT /admin/api/ecommerce/v1/shipping_methods/1?include=translations

This request updates the shipping method with provided attributes.

Example request:

PUT http://helloworld.voog.com/admin/api/ecommerce/v1/shipping_methods/1?include=translations

Example data:

{
  "name": "Normal shipping",
  "translations": {
    "name": {
      "en": "Normal shipping", 
      "et": "Tavatarne"
    },
    "description": {
      "en": "Basic shipping without secondary options", 
      "et": "Tavatarne ilma valikuteta"
    }    
  }  
}

Example response:

Status: 200 OK
{
  "id": 1,
  "name": "Normal shipping",
  "amount": "10.0",
  "description": "Basic shipping without secondary options",
  "enabled": true,
  "created_at": "2016-12-05T14:57:52.000Z",
  "updated_at": "2017-03-30T11:48:07.000Z",
  "tax_rate": null,
  "options": [],
  "translations": {
    "name": {
      "en": "Normal shipping", 
      "et": "Tavatarne"
    },
    "description": {
      "en": "Basic shipping without secondary options", 
      "et": "Tavatarne ilma valikuteta"
    }    
  }  
}

Parameters

  • name — Shipping method name as it appears in the shopping cart dropdown
  • description — A descriptive text that is shown in the shopping cart after selecting the method
  • options — List of strings that are used as sub-options for the method, e.g. possible pickup locations
  • amount — The subtotal amount of the given method
  • tax_rate — The tax rate that is used for the method's total price calculation (defaults to Store's tax_rate if not specified)
  • enabled — A boolean that controls whether the method is rendered in the cart or not

Remove a shipping method

DELETE /admin/api/ecommerce/v1/shipping_methods/1

This request deletes the given shipping method.

Example request:

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

Example response:

Status: 204 No Content