Hi Dean & Noah,
Thanks for the help! I kind-of understand what you are saying but I don’t understand how to make the Velo code syntax understand - lol.
Dean - yes, that formatAddress in the Archive Videos - Level 2, serves no purpose. I left it there because it wasn’t doing anything for now but I had formed it so it was a good start at what I needed in the Popup.
Noah - I love the last line that "you’re returning a string from your formatAddress function when it should be an object”. Honestly, I just don’t know how to turn the array into an object. Probably basic but I’m missing something between the () and {} and $w and …
function formatAddress(addresses) {
console.log("inside formatAddress function", member.contactDetails.addresses);
return addresses.country,
addresses.addressLine,
addresses.addressLine2,
addresses.city,
addresses.subdivision,
addresses.postalCode;
}
I get this in the console.log from within the formatAddress function - an array at first
inside formatAddress function
Array [ {…} ]
0: Object { id: "44f90326-9a9e-433c-bd5b-39463e78d435", addressLine: "1-23 Main St", city: "Queens", … }
addressLine: "1-23 Main St"
city: "Queens"
country: "US"
id: "44f90326-9a9e-433c-bd5b-39463e78d435"
postalCode: "10001"
subdivision: "US-NY"
<prototype>: Object { …
length:
<prototype>: Array []
the Popup code is down to this:
import { lightbox } from 'wix-window'
const { videoData, member } = lightbox.getContext();
console.log("Lightbox content is:", videoData, member);
$w.onReady(function () {
const memberAddress = formatAddress(member.contactDetails.addresses);
console.log("Member Address Info should: ", memberAddress);
$w('#VideoPurchaseForm').setFieldValues({
email_f1d0: member.loginEmail,
first_name_c60f: member.contactDetails.firstName,
last_name_ae59: member.contactDetails.lastName,
long_answer_08ac: videoData.videoTitle,
multi_line_address_6074: memberAddress,
video_date: videoData.videoDate,
});
});
function formatAddress(addresses) {
console.log("inside formatAddress function",member.contactDetails.addresses);
return addresses.country,
addresses.addressLine,
addresses.addressLine2,
addresses.city,
addresses.subdivision,
addresses.postalCode;
}
I’ve tried to use the const but to get the array in the memberAddress but the console.log for “Member Address Info should:” says undefined - while within the formatAddress it’s an array.
Additional attempts at constructing the setFieldValues line for the multi_line_address_6074 that didn’t work (below).
multi_line_address_6074: formatAddress(memberAddress),
multi_line_address_6074: formatAddress(member.contactDetails.addresses),
multi_line_address_6074: member.contactDetails.addresses,
multi_line_address_6074: member.contactDetails.addresses(),
// After setting this:
const memberAddress = formatAddress(member.contactDetails.addresses);
multi_line_address_6074: memberAddress,
multi_line_address_6074: memberAddress(),
// the formatAddress function is below
function formatAddress(addresses) {
console.log("inside formatAddress function",member.contactDetails.addresses);
return [addresses.country,
addresses.addressLine,
addresses.city,
addresses.postalCode
]}
I am also seeing that the console.log for memberAddress is returning a 4-variable array but with undefined values
I think the return in the formatAddress function isn’t doing anything to help. Following the formatAddress, memberAddress is below.
Member Address Info should:
Array(4) [ undefined, undefined, undefined, undefined ]
0: undefined
1: undefined
2: undefined
3: undefined
length: 4
I know I’m probably missing some basic command or syntax to change an array into an object that will magically pop into the multi_line_address_6074 but I’m not seeing it.
Thank you both for the great help! I’m so much further along and am really starting to understand this Velo code 