Skip to content

In Store Pickup API Tutorials

Maksym Novik edited this page Apr 26, 2020 · 9 revisions

Table of Contents

In-Store Pickup API Tutorials

Configure In-Store Pickup delivery

Go to Stores > Configuration > Sales > Delivery Methods and enable In-Store Delivery.

Delivery type Configuration name Enabled by default?
In-Store Delivery in_store No

Next, configure Distance Priority algorithm provider - it is used for filtering pickup locations by distance radius.

Create a Pickup Location

The name, source_code, country_id, and postcode attributes are required for a Source creation.

city, street and phone are required for Pickup Location additionally.

Endpoint
POST http://<host>/rest/all/V1/inventory/sources

Headers
Content-Type application/json
Authorization: Bearer <admin_token>

Payload

{
  "source": {
    "description": " Source #17",
    "source_code": "txspeqs",
    "phone": "(555) 555-5555",
    "email": "[email protected]",
    "postcode": "77010",
    "longitude": -95.383056,
    "enabled": true,
    "contact_name": "Ethan Carter",
    "latitude": 29.762778,
    "region_id": 57,
    "region": "Texas",
    "name": "Texas Sport Equipment Source #017",
    "country_id": "US",
    "city": "Houston",
    "street": "4631 Airport Blvd #125",
    "extension_attributes": {
      "is_pickup_location_active": true,
      "frontend_name": "Sport Equipment Store",
      "frontend_description": "Sport Equipment Store description"
    }
  }
}

Response
Magento returns an empty array.
[]

Search Pickup Locations

inventoryInStorePickupApiGetPickupLocationsV1 API is responsible for searching Pickup Locations. It has a wide variety of request parameters making it quite flexible:

  • area (optional): for searching locations by area defined by a distance radius from the customer address
    • radius (required): search radius in KM, integer value.
    • searchTerm (required): search term string
  • filters (optional) - a set of Pickup Location fields filters. Similar to regular Magento repository's filterGroups field. There are filters by:
    • country (optional)
    • postcode (optional)
    • region (optional)
    • city (optional)
    • street (optional)
    • name (optional)
    • pickupLocationCode (optional)
  • pageSize (optional) - analog of Magento repository's pageSize
  • currentPage (optional) - analog of Magento repository's currentPage
  • scopeType (optional) - Sales Channel Type. Default value is website
  • scopeCode (required) - Sales Channel code. The only one required parameter.
  • sort (optional) - analog of Magento repository's sort
  • extensionAttributes (optional)
    • productsInfo - list of products which that be assigned to each pickup location. Locations without all the products assigned will be filtered out.
      • [0] - single product info node
        • sku (required) - product SKU
        • extensionAttributes - extension point for future customizations

Endpoint
GET http://<host>/rest/all/V1/inventory/in-store-pickup/pickup-locations/

Payload

searchRequest[area][radius]: 1500
searchRequest[area][searchTerm]: Austin
searchRequest[scopeCode]: base
searchRequest[extensionAttributes][productsInfo][0][sku]: SKU1

Response Magento returns Pickup Locations list, search request given and total results count.

{
  "items": [
    {
      "pickup_location_code": "txspeqs",
      "name": "Sport Equipment Store",
      "email": "[email protected]",
      "contact_name": "Ethan Carter",
      "description": "Sport Equipment Store description",
      "latitude": 29.7543,
      "longitude": -95.3609,
      "country_id": "US",
      "region_id": 57,
      "region": "Texas",
      "city": "Houston",
      "street": "4631 Airport Blvd #125",
      "postcode": "77010",
      "phone": "(555) 555-5555"
    }
  ],
  "search_request": {
    "area": {
      "radius": 1500,
      "search_term": "Austin"
    },
    "current_page": 1,
    "scope_type": "website",
    "scope_code": "base",
    "extension_attributes": {
      "products_info": [
        {
          "sku": "SKU1"
        }
      ]
    }
  },
  "total_count": 1
}

Search Pickup Locations using GraphQL

TODO

Place order using In-Store Pickup delivery method

First of all, Configure In-Store Pickup delivery, Create a Pickup Location and proceed with steps 1-8 (except setting delivery method) described in the Order Processing with Inventory Management tutorial.

Find a pickup location suitable for placing the order with. For example, let it be 'Sport Equipment Store' with code txspeqs.

Set In-Store Pickup Delivery method, and the pickup location code.

Endpoint

POST <host>/rest/us/V1/carts/mine/shipping-information (see step 8)

Payload

{
    "addressInformation": {
        "shipping_address": {
            "countryId": "US",
            "regionId": 57,
            "regionCode": "TX",
            "region": "Texas",
            "street": [
                "4631 Airport Blvd #125"
            ],
            "telephone": "(555) 555-5555",
            "postcode": "77010",
            "city": "Houston",
            "firstname": "Sport Equipment Store",
            "lastname": "Store",
            "saveInAddressBook": 0,
            "extension_attributes": {
                "pickup_location_code": "txspeqs"
            }
        },
        "billing_address": {
            "region": "New York",
            "region_id": 43,
            "region_code": "NY",
            "country_id": "US",
            "street": [
                "123 Oak Ave"
            ],
            "postcode": "10577",
            "city": "Purchase",
            "firstname": "Jane",
            "lastname": "Doe",
            "email": "[email protected]",
            "telephone": "512-555-1111"
        },
        "shipping_method_code": "pickup",
        "shipping_carrier_code": "in_store",
        "extension_attributes": {}
    }
}

The rest of the steps are the same as for regular order placing & processing.

Place order using In-Store Pickup delivery method with GraphQL

TODO

Mark Order as Ready for Pickup

Send an email to the customer that order is ready to be picked up, and create a shipment.

Endpoint
POST http://<host>/rest/all/V1/order/notify-orders-are-ready-for-pickup

Headers
Content-Type application/json
Authorization: Bearer <admin_token>

Payload

{
  "orderIds": [
    81
  ]
}

Response

Magento returns an array with success status and array of error messages for each failed order.

{
  "successful": true,
  "failed": []
}

MSI Documentation:

  1. Technical Vision. Catalog Inventory
  2. Installation Guide
  3. List of Inventory APIs and their legacy analogs
  4. MSI Roadmap
  5. Known Issues in Order Lifecycle
  6. MSI User Guide
  7. DevDocs Documentation
  8. User Stories
  9. User Scenarios:
  10. Technical Designs:
  11. Admin UI
  12. MFTF Extension Tests
  13. Weekly MSI Demos
  14. Tutorials
Clone this wiki locally