44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import { logoPath, noReplyEmail, operatorEmail, serverBaseURL } from "../config"
|
|
import { frontendBase } from "../config-client"
|
|
;(function () {
|
|
const oldOrderReturnRequest = context.db.find("orderReturnRequest", {
|
|
filter: {
|
|
_id: context.data.id,
|
|
},
|
|
})[0]
|
|
if (!oldOrderReturnRequest)
|
|
throw {
|
|
message: "Order return request not found",
|
|
code: 404,
|
|
}
|
|
if (oldOrderReturnRequest.status !== context.data.status) {
|
|
const oRR = context.data
|
|
const customer = context.db.find("bigCommerceCustomer", {
|
|
filter: { email: oRR.email },
|
|
})[0]
|
|
|
|
if (!customer) {
|
|
throw {
|
|
status: 404,
|
|
message: "Customer not found",
|
|
}
|
|
}
|
|
const store = {
|
|
logo: `${serverBaseURL}${logoPath}`,
|
|
frontendBase,
|
|
}
|
|
const html = context.tpl.execute(context.fs.readFile("templates/statusUpdateReturnRequest.html"), {
|
|
store,
|
|
})
|
|
|
|
context.smtp.sendMail({
|
|
to: oRR.email,
|
|
from: operatorEmail,
|
|
fromName: "BinKrassDuFass",
|
|
replyTo: noReplyEmail,
|
|
subject: "Stornierung Ihrer Bestellung",
|
|
html,
|
|
})
|
|
}
|
|
})()
|