Skip to content

Commit

Permalink
chore: replace post metafields to patch
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgnreis authored Aug 6, 2024
1 parent 6a83bd4 commit f4168b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions functions/lib/buzzlead/send-conversions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ module.exports = async ({ appSdk, storeId, auth }, order, appData) => {
console.log('response data', response.data)
if (response.status === 201) {
const responseData = response.data
const metafields = order.metafields || []
metafields.push({
_id: ecomUtils.randomObjectId(),
field: 'buzzlead:send',
value: order.number
})
console.log('Request successful:', responseData)
await appSdk.apiRequest(
storeId,
`/orders/${order._id}/metafields.json`,
'POST',
`/orders/${order._id}.json`,
'PATCH',
{
_id: ecomUtils.randomObjectId(),
field: 'buzzlead:send',
value: order.number
metafields
},
auth
)
Expand Down
14 changes: 9 additions & 5 deletions functions/lib/buzzlead/update-conversions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@ module.exports = async ({ appSdk, storeId, auth }, order, appData) => {
if (response.status === 201) {
const responseData = response.data;
console.log('Request successful:', responseData);
const metafields = order.metafields || []
metafields.push({
_id: ecomUtils.randomObjectId(),
field: 'buzzlead:update',
value: order.number
})
await appSdk.apiRequest(
storeId,
`/orders/${order._id}/metafields.json`,
'POST',
`/orders/${order._id}.json`,
'PATCH',
{
_id: ecomUtils.randomObjectId(),
field: 'buzzlead:update',
value: order.number
metafields
},
auth
)
Expand Down

0 comments on commit f4168b2

Please sign in to comment.