Create locations

To maintain inventory for individual physical stores or web sites, you must represent them in Oracle Commerce by creating new locations.

Create physical locations

Use the createLocation endpoint to create a new physical location. You specify information about the location in the body of the request. The following example creates a physical location for a warehouse:

POST /ccadmin/v1/locations HTTP/1.1
Authorization: Bearer <access_token>

{
  "externalLocationId": "107",
  "locationId": "Warehouse13",
  "address1": "221 Third Street",
  "country": "USA",
  "city": "Cambridge",
  "faxNumber": "(617) 386-1200",
  "postalCode": "02141",
  "phoneNumber": "(617) 386-1200",
  "email": "wh13@example.com",
  "stateAddress": "MA",
  "county": "Middlesex",
  "name": "Warehouse 13 -- 02141",
  "longitude": -71.0901,
  "latitude": 42.3629
}

You must supply a value for the name property. If you omit locationId (the property used to identify the location in REST API calls), a value is automatically supplied. If you omit other properties, their values will be null.

The endpoint returns the location information in the response body:

{
  "country": "USA",
  "distance": null,
  "city": "Cambridge",
  "endDate": null,
  "postalCode": "02141",
  "latitude": 42.3629,
  "county": "Middlesex",
  "stateAddress": "MA",
  "pickUp": false,
  "sites": [],
  "type": "location",
  "inventory": false,
  "locationId": "Warehouse13",
  "email": "wh13@example.com",
  "longitude": -71.0901,
  "address3": null,
  "address2": null,
  "address1": "221 Third Street",
  "externalLocationId": "107",
  "phoneNumber": "(617) 386-1200",
  "siteGroups": [],
  "repositoryId": "Warehouse13",
  "name": "Warehouse 13 -- 02141",
  "faxNumber": "(617) 386-1200",
  "startDate": null
}

Understand site inventory locations

When a shopper accesses a Product Display page, the page displays the item’s stock level at the site’s specified inventory location. An inventory check is also made when a shopper adds to or decreases the amount of an item in a cart.

Location-based inventory allows each of your web sites to be served by its own inventory. Once you have mapped a specific web site to an inventory, transactions will display the relevant inventory levels. Oracle Commerce identifies a site’s inventory location and uses that location throughout the shopper’s session. This means that any inventory checks made during the session are location-aware. For example, when an order is submitted, the inventory decrement occurs on the inventory linked to the site.

A site can be mapped to a default inventory location. If no inventory mapping for a site is detected, the system uses the default inventory location.

The shipFrom location based on the storefront’s inventory location is used to calculate shipping costs. A hard goods shipping group is created when a cart item is identified as being shipped to a physical address.

Create a web site inventory location

Before you can create an inventory location for your site, you must create or update a site to use the inventoryLocationId property. Use the site endpoint to set a default inventory location ID for a custom site that contains the inventoryLocationId. For example:

POST /ccadmin/v1/sites HTTP/1.1
Authorization: Bearer <access_token>

{
  "properties": {
    "repositoryId": "CustomSite2",
    "name": "Custom Site 2",
    "defaultCatalog": {
      "repositoryId": "ClassicalMoviesCatalog"
    },
    "inventoryLocationId": "WH12",
    "enabled": true
  }
}

Once you have the site configured with the inventory location ID, you can create a location. Set the site’s location ID and include the custom site in the sites array:

POST /ccadmin/v1/locations HTTP/1.1
Authorization: Bearer <access_token>

{
  "country": "USA",
  "address3": null,
  "endDate": "2017-04-25",
  "address2": "Building 4",
  "city": "Glen Allen",
  "address1": "4870 Sadler Rd.",
  "latitude": 37.6659833,
  "postalCode": "23060",
  "county": "Henrico",
  "stateAddress": "VA",
  "externalLocationId": "187",
  "phoneNumber": "(617) 637-8687",
  "locationId": "Warehouse12",
  "name": "Warehouse 12 --23060",
  "faxNumber": "(617) 386-1200",
  "startDate": "2016-04-25",
  "email": "wh12@example.com",
  "longitude": -77.5063697
}

You can determine when and if inventory levels are decremented by identifying the specific inventory location for each SKU or product. The default inventory is decremented if you do not configure an inventory location.

Note the following:

  • A site that contains a null inventoryLocationId returns records from a null inventory
  • A site that contains an inventoryLocationId that is mapped to a location but not mapped to an inventory record empties inventory records with a status of IN_STOCK.

Once the locations are defined, you must associate an inventory record with a location as described in the Create inventory data for locations section.

List locations

Use the listLocations endpoint to retrieve a listing of all locations:

GET /ccadmin/v1/locations HTTP/1.1
Authorization: Bearer <access_token>

You can use query parameters to restrict the set of locations returned.

Modify a location

Use the updateLocation endpoint to modify a location:

PUT /ccadmin/v1/locations/Warehouse13 HTTP/1.1
Authorization: Bearer <access_token>

{"postalCode": "02141"}

Delete a location

Use the deleteLocation endpoint to delete a location:

DELETE /ccadmin/v1/locations/Warehouse13 HTTP/1.1
Authorization: Bearer <access_token>

Delete a location currently in use

If you remove active locations from a custom site, the following may occur:

  • Returns will no longer be possible for removed locations
  • The location ID property is not removed; references to it will remain on your site / inventory
  • The Ship From address defaults to the site’s default
  • Historic orders will reference the location used when the order was placed