Initial commit
This commit is contained in:
12
api/hooks/wishlist/get_read.js
Normal file
12
api/hooks/wishlist/get_read.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const { withAccount } = require("../lib/utils")
|
||||
const { getWishlistEntries } = require("../lib/bigcommerceRestAPI.js")
|
||||
;(function () {
|
||||
withAccount((login) => {
|
||||
const customerId = login.bigCommerceId
|
||||
const wishlist = getWishlistEntries(customerId)
|
||||
throw {
|
||||
status: 200,
|
||||
data: wishlist,
|
||||
}
|
||||
})
|
||||
})()
|
||||
35
api/hooks/wishlist/post_create.js
Normal file
35
api/hooks/wishlist/post_create.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const { removeWishlistEntry } = require("../lib/bigcommerceRestAPI.js")
|
||||
const { withAccount } = require("../lib/utils")
|
||||
const { createWishlistEntry } = require("../lib/bigcommerceRestAPI.js")
|
||||
;(function () {
|
||||
withAccount((login) => {
|
||||
const productId = context.data.productId
|
||||
const variantId = context.data.variantId
|
||||
const customerId = login.bigCommerceId
|
||||
if (context.data.delete) {
|
||||
if (!productId || !variantId) {
|
||||
throw {
|
||||
message: "Invalid product or variant id",
|
||||
code: 400,
|
||||
}
|
||||
}
|
||||
const wishlist = removeWishlistEntry(customerId, productId, variantId)
|
||||
throw {
|
||||
status: 200,
|
||||
data: wishlist,
|
||||
}
|
||||
}
|
||||
|
||||
if (!productId || !variantId) {
|
||||
throw {
|
||||
message: "Invalid product or variant id",
|
||||
code: 400,
|
||||
}
|
||||
}
|
||||
const wishlist = createWishlistEntry(productId, variantId, customerId)
|
||||
throw {
|
||||
status: 200,
|
||||
data: wishlist,
|
||||
}
|
||||
})
|
||||
})()
|
||||
Reference in New Issue
Block a user