Initial commit
This commit is contained in:
43
api/hooks/orderRevokeRequest/put_update.js
Normal file
43
api/hooks/orderRevokeRequest/put_update.js
Normal file
@@ -0,0 +1,43 @@
|
||||
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,
|
||||
})
|
||||
}
|
||||
})()
|
||||
Reference in New Issue
Block a user