productDetails

Gets pricing and product details for a specific product in a webstore. Use this wire adapter in Order Management repricing scenarios.

Syntax 

1import { LightningElement, wire } from 'lwc';
2import { productDetails } from 'lightning/commerceRepricingApi';
3
4@wire(productDetails, { webstoreId: string, skuOrProductId: string, version: string })
5propertyOrFunction

Commerce API Resource 

1GET /commerce/order-management/webstores/{webstoreId}/products/{skuOrProductId}

productDetails uses this Commerce API resource.

Parameters 

  • webstoreId—(Required) The ID of the webstore. The ID prefix is 0ZE.
  • skuOrProductId—(Required) The SKU or product ID to look up.
  • version—(Required) The API version for the adapter, for example, v62.0. Without this parameter, the wire doesn’t fire.
  • effectiveAccountId—(Optional) The effective account ID for buyer-specific pricing and entitlements.
  • currencyCode—(Optional) The ISO currency code for pricing, for example, USD.
  • locale—(Optional) The locale for localized product content, for example, en-US.
  • excludeAttributeSetInfo—(Optional) Set to true to exclude attribute set information from the response. Available in API version 44.0 and later.
  • excludeMedia—(Optional) Set to true to exclude media from the response. Available in API version 44.0 and later.
  • excludeQuantityRule—(Optional) Set to true to exclude the purchase quantity rule from the response. Available in API version 44.0 and later.
  • excludeVariationInfo—(Optional) Set to true to exclude variation information from the response. Available in API version 44.0 and later.
  • excludePrices—(Optional) Set to true to exclude prices from the response. Available in API version 44.0 and later.
  • excludeBundleChildrenInfo—(Optional) Set to true to exclude bundle children information from the response. Available in API version 56.0 and later.

Returns 

  • data—A ProductDetailsOutputRepresentation object with these fields:
    • productId—The product ID.
    • stockKeepingUnit—The SKU.
    • name—The product name.
    • description—The product description.
    • productClass—The product class. Valid values: Bundle, Simple, Variation, VariationParent, Set.
    • totalChildrenCount—The number of children for a bundle product.
    • fields—A map of requested product fields.
    • variants—A list of product variants.
    • imageGroups—A list of product media image groups.
    • unitPrice—The unit price.
    • listPrice—The list price.
    • attributes—A list of variation attributes.
    • currencyIsoCode—The ISO currency code.
    • productQuantityRule—The purchase quantity rule.
    • childItems—A list of bundle child items.
    • success—Indicates whether the request was successful.
    • errors—A list of errors, if any. Each error has errorCode, message, and errorEntityId fields.
  • errorFetchResponse

Usage 

1import { LightningElement, wire } from 'lwc';
2import { productDetails } from 'lightning/commerceRepricingApi';
3
4export default class ProductDetailsExample extends LightningElement {
5  webstoreId = '0ZExx0000000001';
6  skuOrProductId = '01t000000000001';
7
8  @wire(productDetails, {
9    webstoreId: '$webstoreId',
10    skuOrProductId: '$skuOrProductId',
11    version: 'v62.0',
12    effectiveAccountId: '$effectiveAccountId',
13  })
14  product;
15
16  get productName() {
17    return this.product?.data?.name;
18  }
19
20  get unitPrice() {
21    return this.product?.data?.unitPrice;
22  }
23}

Error Handling 

If the wire adapter encounters an error, data is undefined and error contains the error details.

See Also