Initial commit
This commit is contained in:
25
api/hooks/cart/post_validate.js
Normal file
25
api/hooks/cart/post_validate.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const { addCartItem, updateCartItem, deleteCartItem, getCart } = require("../lib/bigcommerceRestAPI")
|
||||
const { postAddToCart } = require("../lib/facebookRestAPI")
|
||||
|
||||
;(function () {
|
||||
const operation = context?.data?.operation
|
||||
|
||||
if (operation == "add") {
|
||||
addCartItem(context?.data?.cartId, context?.data?.lineItems)
|
||||
try {
|
||||
postAddToCart()
|
||||
} catch (e) {}
|
||||
} else if (operation == "update") {
|
||||
updateCartItem(context?.data?.cartId, context?.data?.lineItem, context?.data?.entityId)
|
||||
try {
|
||||
postAddToCart()
|
||||
} catch (e) {}
|
||||
} else if (operation == "delete") {
|
||||
deleteCartItem(context?.data?.cartId, context?.data?.entityId)
|
||||
}
|
||||
|
||||
throw {
|
||||
status: 200,
|
||||
message: "success",
|
||||
}
|
||||
})()
|
||||
Reference in New Issue
Block a user