findOrdersByPhone
function allows you to retrieve orders associated with a customer by using the provided phone number. When executed within the Execute JavaScript block, it checks for the existence of orders in the system and, if found, returns an array containing complete details about the orders linked to the phone number, including customer information, purchased items, and payment status.
payload.phone
.
findOrdersByPhone
function and retrieve the orders associated with the provided phone number.
payload.orders = await findOrdersByPhone(payload.phone)
to retrieve orders associated with the phone number provided by the customer. This way, the phone number stored in the payload.phone
variable is passed to the findOrdersByPhone
function to search for orders linked to that number. The result is stored in payload.orders
as an array containing the matching orders.
Example Code
for
and if/else
structures. These commands allow for detailed and conditional formatting of the displayed information. To deepen your understanding of Reportana® Script and explore additional examples, refer to the full documentation: Reportana® Script - Documentation.
findOrdersByPhone
Function