update routes/admin.js to fix bug deleting product options

master
Marty Sloan 2018-06-21 20:40:53 -04:00 committed by Mark Moffat
parent ad6ca4ba60
commit b9caca8794
1 changed files with 2 additions and 2 deletions

View File

@ -187,11 +187,11 @@ router.post('/admin/settings/option/remove', common.restrict, common.checkAccess
let optJson = JSON.parse(product.productOptions); let optJson = JSON.parse(product.productOptions);
delete optJson[req.body.optName]; delete optJson[req.body.optName];
db.products.update({_id: common.getImages(req.body.productId)}, {$set: {productOptions: JSON.stringify(optJson)}}, (err, numReplaced) => { db.products.update({_id: common.getId(req.body.productId)}, {$set: {productOptions: JSON.stringify(optJson)}}, (err, numReplaced) => {
if(err){ if(err){
console.info(err.stack); console.info(err.stack);
} }
if(numReplaced === 1){ if(numReplaced.result.nModified === 1){
res.status(200).json({message: 'Option successfully removed'}); res.status(200).json({message: 'Option successfully removed'});
}else{ }else{
res.status(400).json({message: 'Failed to remove option. Please try again.'}); res.status(400).json({message: 'Failed to remove option. Please try again.'});