The window._context
object represents product-related information stored within the JavaScript environment of the current browser session. It encapsulates essential details about a specific product listed on the page, such as its attributes, pricing, availability, and metadata.
- Specifies the type of resource this object represents, which in this case is
"products"
.
- Contains the main data related to the product.
- The unique identifier for this product.
- Stock Keeping Unit (SKU) code for the product.
- The name or title of the product.
- The SEO meta title of the product.
- The SEO meta description of the product.
- The price of the product in the specified currency (
BRL
).
- The cost price of the product.
-
The physical dimensions of the product.
width
(Object)unit
: Unit of measurement (cm
). Can be m, mm or others, by default iscm
value
: Width value.
height
(Object)unit
: Unit of measurement (cm
).value
: Height value.
length
(Object)unit
: Unit of measurement (cm
).value
: Length value.
-
The weight of the product.
unit
: Unit of measurement (kg
). Can be g, dm or others, by default iscm
value
: Weight value.
-
Variations of the product (e.g., color, size).
Array of product variations.
Each variation object contains:
`_id` (String): Unique identifier for the variation. `name` (String): Name of the variation. `sku` (String): Stock Keeping Unit (SKU) code for the variation. `quantity` (Number): Available quantity of this variation. `specifications` (Object): Specifications of the variation. `size (Array): Array containing size`or any grade specifications. `text`: Variation text. `value`: Variation value. **Obs**: Only in colors variation, the value must be the color in hexadecimal.
- The available quantity of the product in stock.
- Keywords associated with the product.
- Array of brands associated with the product.
Array of categories to which the product belongs.
Each category object contains:
`_id` (String): Unique identifier for the category.
`name` (String): Name of the category.
`slug` (String): slug of the category.
- Detailed specifications of the product.
- Type of commodity (
physical
).
- Indicates whether the product is available for purchase (
true
) or not (false
).
- Indicates whether the product is visible (
true
) or hidden (false
).
- Array of images representing the product.
- Date and time when the product information was last updated.
- Date and time when the product was created.
- Records of inventory associated with the product.
// Accessing product details
const productName = window._context.body.name;
const productPrice = window._context.body.price;
const productDescription = window._context.body.body_html;
// Checking availability
const isAvailable = window._context.body.available;
// Accessing product dimensions
const productDimensions = window._context.body.dimensions;
// Retrieving product pictures
const productPictures = window._context.body.pictures;
// Viewing brand information
const productBrand = window._context.body.brands[0].name;
- Ensure that the
window._context
object is properly initialized and contains valid data before accessing its properties. - The structure and contents of
window._context
may vary based on the specific implementation and requirements of the product page.
This documentation outlines the structure and key properties of the window._context
object, providing a clear understanding of the product-related data it encapsulates. Adjustments can be made based on actual observations and requirements specific to your implementation. If you have any further questions or need additional clarification on specific properties, please feel free to ask!