Hello everyone,
I have an NodeJS app where I’m allowing our users to order our products for free. Considering that is free, I didn’t want to send them to the Shopify’s checkout page (that I usually do) but rather get unnecessary data and create an order from our app using Shopify’s API.
And that worked perfectly, order is made in the Shopify BUT no order confirmation email is sent to the user, which I would like to be sent so our customers are aware that they did order product successfully.
I though that will happen automatically, but that is not the case.
Do you maybe know how I can trigger that email?
I’m using @shopify/shopify-api.
Function for creating order looks like this:
async createOrder(orderData, userId) {
const session = {
shop: shopify.shopName,
accessToken: shopify.accessToken,
};
const order = await this.generateShopifyOrderData(orderData, userId);
try {
const client = new this.shopify.clients.Rest({ session });
const response = await client.post({
path: 'orders',
data: { order },
type: 'application/json',
});
return response.body;
} catch (error) {
throw new UnableToCreateEntityInShopify('Error happened while trying to create order in Shopify', error);
}
}
And order object that I’m sending looks like this:
const order = {};
order.line_items = [
{
variant_id: variantId,
quantity: 1,
},
];
order.customer = {
first_name: firstName,
last_name: lastName,
email,
};
order.billing_address = {
first_name: firstName,
last_name: lastName,
address1,
address2,
city,
company,
country,
zip,
};
order.shipping_address = {
first_name: firstName,
last_name: lastName,
address1,
address2,
company,
city,
country,
zip,
};
order.email = email;
order.financial_status = 'paid';
order.discount_codes = [
{
code: 'XXXXXX',
amount: '100.00',
type: 'percentage',
},
];
order.shipping_lines = [shippingLines];
Thank you!