Automatic e-mails after placing an order

I needed to redesign the WIX store and I have a problem with automatic emails that are sent after placing the order.
I need to add the price for the payment method to the total amount of the order - cash on delivery, but in Wix store are offline payments free, so I wanted to create my own emails (triggeret emails). However, since I am new to coding, I do not know how to get to the order number after creating an order. I don’t use the Thank you page in the store, the whole purchase process takes place on the cart page - I did something like a multi-level form, which is used to store all the necessary information on the createOrder (fullOrder) in the variable “fullOrder” (on the page code, not in the backend).
When the code runs out:

.then((order) => {
console.log(order.number) // return undefined
.catch((error) => {

the order is created, but order number is undefined.

What do i wrong? How do I get the output of the function/api createOrder(), or do you have any other idea?