Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Real-time stock check webhook.

This runtime action exposes a web entry point to check the available stock for commerce cart items in real time. You must implement the logic to check the stock on the external service. The response of this runtime is adapted for Commerce webhook module to allow intercepting flows in Adobe commerce.

Alt text

Input information

Here is the payload JSON example:

{
  "data": {
    "cart_id": "cart id",
    "items": [
      {
        "item_id": 1,
        "sku": "Product SKU",
        "qty": "Cart item qty"
      }
    ]
  }
}

Validation

The parameters (data, data.cart_id, and data.items) are required. The validation logic is found on the file webhook\check-stock\validator.js. If needed, you can add more validations to the validateData method in this file.

Check available stock

This runtime uses the method checkAvailableStock() in the file webhook\check-stock\stock.js. You must implement the method's logic to check the stock availability for the items received in params. The method should return the following in the case of:

Items stock available:

return {
  success: false
}

Items stock not available:

return {
  success: false,
  message: 'Some custom error like stock not available for items.'
}

Use extra env parameters

You can access any needed environment parameter from params. Add the required parameter in the actions/webhook/check-stock/actions.config.yaml under check-stock -> inputs as follows:

check-stock:
  function: check-stock/index.js
  web: 'yes'
  runtime: nodejs:20
  inputs:
    LOG_LEVEL: debug
    
    HERE_YOUR_PARAM: $HERE_YOUR_PARAM_ENV
    
  annotations:
    require-adobe-auth: false
    final: true