Add a comment to a product

Add a comment to product

swat.addComment

Adds a Comment to a product

Definition

swat.addComment(options, onSuccess, onError)

Example

Here's an example of how you can use this API to add Comment to a List Item :

// Define the opts
let options = {
  listitemcomments: [
      {
        "txt":"Some item comment",
        "empi":123,
        "epi":111,
        "lid":"list-id"
      }
    ]
}

// Define success callback
let onSuccess = function(commentsObj) { 
  // Executed when comments are successfully added
  console.log("Successfully added Comments to List Item", commentsObj);
}

// Define error callback
let onError = function(error) {
  // Error is an xhrObject
  console.log("Error while adding Comments to List Item", error);
}

swat.addComment(options, onSuccess, onError);

API Parameters

ArgumentTypeDescription
optionsobjectAn options object with a List Item Comment Input array
listitemcommentsarrayAn array of List Item Comment Input
onSuccessfunctionCalled when the List Comments are successfully added to the List Item.
onErrorfunctionCalled when there is an error while fetching the List Comments to the List Item.

Success Response

{
  "listcomments": [],
  "listitemcomments": [
    {
      "cid": "comment-id",
      "txt": "Some new comments",
      "lid": "list-id",
      "empi": 123,
      "epi": 111,
      "cts": 145555555511
    }
  ]
}

Other References

List Item Comment Input

An object containing params required for creating new list item comment

let listItemCommentDef = {
  "lid": "list id", 
  "empi": "Product master id",
  "epi": "Product variant id",
  "txt": "Comment text",
  "cprops": {} // optional param
};
ArgumentTypeRequiredDescription
lidstringYesUnique id of the List to add Comment
empinumber/stringYesProduct master id of the List Item to add Comment
epinumber/stringYesProduct Variant id of the List Item to add Comment
txtstringYesComment content
cpropsobjectoptionalMap of custom fields