How to get Item Info in PDP.

Description :
Gets information about the item in the current product details page (PDP), which may include details such as the item quantity, shipping address, or fulfillment choice. Information may also include data from custom fields. The actual values returned will depend on how the item is configured in NetSuite. This method only works if the current view is a PDP.

var pdp = container.getComponent("PDP");
var iteminfo = pdp.getItemInfo(); // Example of the object returned from getItemInfo()
{
  "item": {
    "displayname": "Cotton Shirt",
    "internalid": 7101,
    "isinstock": true,
    "quantityavailable": 8,
    ...
  },
  "options": [
    {
    "cartOptionId": "custcol14",
    "itemOptionId": "custitem30",
    "label": "Size",
    "values": [
      {
        "internalid": "2",
        "label": "Small"
      },
      {
        "internalid": "4",
        "label": "Medium"
      }
    ]
    }
  ],
  "quantity": "1"
}

We can use dot notation to access the object properties. For Example

item.internalid – The internal ID of the item in NetSuite.
item.isinstock – Indicates if inventory is available.
options.cartOptionId – The name of an option on the product details page. Use the value of this property as the first argument in setOption() when setting an option.
options.values.internalid – The internal ID of the option value. Use the value of this property as the second argument in setOption() when setting an option.
options.values.label – The label of the option as it appears on the product details page.

Note: This method may return price information for the item, but it will only return the price for the currently selected options and quantity. Use getPrice() to get additional price information.

Return Values :
Returns an ItemInfo object with information about the item. If the Store Pickup feature is enabled in the NetSuite account, it also returns item information related to store pickup, such as the quantity of items available for store pickup. If the current view is not in the PDP component, it returns null.

ItemInfo :

Name                            Type      Attributes    Description
internalid                      String    <optional>
type                            String    <optional>
onlinecustomerprice_detail      String    <optional>

Leave a comment

Your email address will not be published. Required fields are marked *