Adds default shipping profile
This commit is contained in:
@@ -43,6 +43,8 @@ export default async (req, res) => {
|
||||
delete value.variants
|
||||
|
||||
const productService = req.scope.resolve("productService")
|
||||
const shippingProfileService = req.scope.resolve("shippingProfileService")
|
||||
|
||||
let newProduct = await productService.createDraft(value)
|
||||
|
||||
if (variants) {
|
||||
@@ -64,6 +66,10 @@ export default async (req, res) => {
|
||||
)
|
||||
}
|
||||
|
||||
// Add to default shipping profile
|
||||
const { _id } = await shippingProfileService.retrieveDefault()
|
||||
await shippingProfileService.addProduct(_id, newProduct._id)
|
||||
|
||||
newProduct = await productService.decorate(newProduct, [
|
||||
"title",
|
||||
"description",
|
||||
|
||||
@@ -27,10 +27,17 @@ export default async (req, res) => {
|
||||
|
||||
try {
|
||||
const optionService = req.scope.resolve("shippingOptionService")
|
||||
const shippingProfileService = req.scope.resolve("shippingProfileService")
|
||||
|
||||
const data = await optionService.create(value)
|
||||
|
||||
// Add to default shipping profile
|
||||
const { _id } = await shippingProfileService.retrieveDefault()
|
||||
await shippingProfileService.addProduct(_id, data._id)
|
||||
|
||||
res.status(200).json({ shipping_option: data })
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user