I’m using .getcurrentItem(); to pull through a product onto my page.
I’m trying to pull through 3 Additional Info Sections but can’t work out the next step.
Any help would be appreciated.
I’m using .getcurrentItem(); to pull through a product onto my page.
I’m trying to pull through 3 Additional Info Sections but can’t work out the next step.
Any help would be appreciated.
Hi,
The Additional info is Array of Object so to access to it you can use the following example code:
let product = $w(‘#dataset2’).getCurrentItem()
let ArrayAdditionaInfo = []
ArrayAdditionaInfo = product.additionalInfoSections
ArrayAdditionaInfo.forEach((element) => {
console.log(element)
console.log(element.title)
console.log(element.description)
})
good luck, Erez
Hi,
The Additional info is Array of Object so to access to it you can use the following example code:
let product = $w(‘#dataset2’).getCurrentItem()
let ArrayAdditionaInfo = []
ArrayAdditionaInfo = product.additionalInfoSections
ArrayAdditionaInfo.forEach((element) => {
console.log(element)
console.log(element.title)
console.log(element.description)
})
good luck, Erez
Hi Erez,
Could you explain what I would need to change in your code example to get this to work? I too am trying to pull the data from the additional info sections onto a custom dynamic product page. I have managed to pull the product options data using the code below, but the additional info section is giving me a hard time. I think because I cant find a code example of it actually working. Here is a link to the page if that helps, https://www.perfectlygiftedfrisco.com/PGFProducts/Warmie-Swig-Sippy-Cup-Set/2, thanks in advance!! -Mallory
export function dynamicDataset_ready() {
// Get the product data from the current item.
const currentProduct = $w(“#dynamicDataset”).getCurrentItem().product;
// Get the product options from the product data.
const productOptions = currentProduct.productOptions;
// Set the product option repeater with the choices from the product’s Product Option option.
$w(‘#productOptionRepeater’).data = createColorRepeaterData(‘productoption’, productOptions[‘Product Option’].choices);
}
// Add an ID to the choices data so it can be used to populate a repeater.
function createColorRepeaterData(idPrefix, choices) {
// Use the JavaScript map() function to add an _id field to each data item.
return choices.map((item, index) => {
item._id = ${idPrefix}-${index}
;
return item;
});
}
// Each item has a box that contains its color and a transparent button layered on top of the box.
export function productOptionRepeater_itemReady($w, itemData, index) {
// Set the current box’s color to be the color from the current item’s data.
$w(‘#productOptionBox’).style.backgroundColor = itemData.value;
$w(‘#productOptionText’).text = itemData.description;
// Set the action that occurs when a user clicks the current thread color button.
$w(‘#productOptionBtn’).onClick(() => {
// Call the updateProductOption() function with the current item’s data.
updateProductOption(itemData)
});
}
// Update the color
function updateProductOption(colorItem) {
// Set the text label in the color chooser to be the specified color.
$w(‘#productOptionChoice’).text = colorItem.description;
}