Skip to content

Commit

Permalink
fix: saving correct tracking code in place of this non-sense "rastrei…
Browse files Browse the repository at this point in the history
…o" custom field
  • Loading branch information
leomp12 committed Sep 2, 2024
1 parent d0380bc commit 820867c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions functions/lib/mandabem/create-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,17 @@ module.exports = ({ appSdk, storeId, auth }, {
).then(({ data }) => {
console.log('Tag created with success', order._id)
if (String(data?.resultado?.sucesso) === 'true') {
const customFields = shippingLine.custom_fields || []
customFields.push({
field: 'rastreio',
value: String(data.resultado.envio_id)
const trackingId = String(data.resultado.envio_id)
const trackingCodes = shippingLine.tracking_codes || []
trackingCodes.push({
code: trackingId,
tag: 'mandabem'
})
return appSdk.apiRequest(
storeId,
`/orders/${order._id}/shipping_lines/${shippingLine._id}.json`,
'PATCH',
{ custom_fields: customFields },
{ tracking_codes: trackingCodes },
auth
)
}
Expand Down
2 changes: 1 addition & 1 deletion functions/routes/ecom/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ exports.post = ({ appSdk }, req, res) => {
res.send(ECHO_SKIP)
return
}

let auth, mandaBemId, mandaBemKey, warehouses
appSdk.getAuth(storeId)
.then(_auth => {
Expand Down

0 comments on commit 820867c

Please sign in to comment.