How to get the customTextFields values on order paid

Hello everyone !

I have a little question, I cannot find how to get the custom text fields values on orderpaid event.

That’s my code:

import wixData from 'wix-data';

export function wixStores_onOrderPaid(event) {
    for (let i = 0; i < event.lineItems.length; i++) {
        let toInsert = {"details": `${event.lineItems[i].name} ${event.lineItems[i].quantity} ${event.lineItems[i].customTextFields}`};
        wixData.insert("API_Boutique", toInsert)
    }
}

The code is working except the customtextfields expression, I tried a lot of syntax like “${event.lineItems[i].customTextFields.value}” or “${event.lineItems[i].customTextFields[1].value}”, …
But that just give me an undefined value or default object value:


The name section is working, the quantity expression too. But not the customTextFields value.

The event tutorial: https://www.wix.com/velo/reference/wix-stores-backend/events/onorderpaid


I just want to know how can I get the values of this section. Thanks !

Ok, I just solved the problem. I just forgot that loops start on 0 and not 1. So the expression is ${ event . lineItems [ i ]. customTextFields[0].value } and not ${ event . lineItems [ i ]. customTextFields[1].value }. SOLVED !

Thank you for sharing this! I having been struggling with how to do what you are doing but with a product option (variant). Just figured it out. Here it is for others.

“school” : event . lineItems [ i ]. options [ 0 ]. selection ,