Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

NeedInfo

NeedInfo

Note: As of Elastic Path 7.1, NeedInfos are provided for backwards compatability with older Cortex API resources. To implement blocking functionality on a form, use Advisors.

Needinfos are a hypermedia control that prevent a resource from changing its state until a set of conditions are satisfied. Needinfos are generally used to control a button's enabled state on the user interface.

NeedInfo Example: Completing a Purchase

The purchase form resource creates a purchase. The submitorderaction link appears on the purchase form when the purchases preconditions are satisfied and a purchase can be placed. Below is a purchase form with its preconditions satisfied.
{
  "self": {
    "type": "elasticpath.purchases.purchase",
    "uri": "/commerce-legacy/purchases/orders/mobee/mu3=/form",
    "href": "http://api.elasticpath.net/cortex/purchases/orders/mobee/mu3=/form"
  }  
  "links": [
    {
      "rel": "submitorderaction",
      "uri": "/commerce-legacy/purchases/orders/mobee/mu3=",
      "href": "http://api.elasticpath.net/cortex/purchases/orders/mobee/mu3="
    }
  ]
}    
If a purchases preconditions are not satisfied and more information is required from the shopper, needinfo links appear instead of the submitorderaction link for each piece of missing information. needinfos points to an info resource that allows the shopper to select or create the missing data. The example below shows needinfos appearing on a purchase form.
{
  "self": {
    "type": "elasticpath.purchases.purchase",
    "uri": "/commerce-legacy/purchases/orders/mobee/mu3=/form",
    "href": "http://api.elasticpath.net/cortex/purchases/orders/mobee/mu3=/form"
  }  
  "links": [
    {
      "rel": "needinfo",
      "type": "elasticpath.controls.info",
      "uri": "/commerce-legacy/orders/mobee/grr=/billingaddressinfo",
      "href": "http://api.elasticpath.net/cortex/orders/mobee/grr=/billingaddressinfo"
    },    
    {
      "rel": "needinfo",
      "type": "elasticpath.controls.info",
      "uri": "/commerce-legacy/orders/mobee/grr=/emailinfo",
      "href": "http://api.elasticpath.net/cortex/orders/mobee/grr=/emailinfo"
    }
  ]
}