Currently, I am in the process of modifying some code and I need to introduce a new variable to an array. The initial code is functioning perfectly:
submit.addAttributeValue = function() {
var aValue = submit.status.newAttributeValue;
var aType = submit.status.selectedAttributeType;
console.log('adding value', aValue, aType)
if(aValue && aType) {
submit.ProductMeta['attributes'][aType][aValue] = true;
};
};
My intention was to include the variable 'aPrice' in the function:
submit.addAttributeValue = function() {
var aValue = submit.status.newAttributeValue;
var aType = submit.status.selectedAttributeType;
var aPrice = submit.status.newAttributePrice;
console.log('adding value', aValue, aType, aPrice)
if(aValue && aType) {
submit.ProductMeta['attributes'][aType][aValue][aPrice] = true;
};
};
However, upon doing this, I encountered the following error:
Error: submit.ProductMeta.attributes[aType][aValue] is undefined
submit.addAttributeValue@http://dubdelivery.com/js/controllers-submit.js:369:13
Just to clarify, ProductMeta is initialized as: submit.ProductMeta = {};
Any suggestions on how I should proceed with this issue?
Thank You!