Skip to content

Commit

Permalink
fix: cleaning special chars from order notes on export
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 authored Nov 5, 2024
1 parent e1e69ce commit 33b401a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion functions/lib/integration/parsers/order-to-tiny/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,16 @@ module.exports = (order, appData, storeId) => {
}

if (order.notes) {
tinyOrder.obs = order.notes.substring(0, 100)
let cleanNotes = ''
for (let i = 0; i < order.notes.length; i++) {
if (order.notes.charCodeAt(i) <= 255) {
cleanNotes += order.notes.charAt(i)
if (cleanNotes.length > 99) break
}
}
if (cleanNotes) {
tinyOrder.obs = cleanNotes
}
}
if (order.extra_discount && order.extra_discount.discount_coupon) {
tinyOrder.obs = `${(tinyOrder.obs || '')} - ${order.extra_discount.discount_coupon}`.substring(0, 100)
Expand Down

0 comments on commit 33b401a

Please sign in to comment.