fix(medusa-plugin-addon): Fixes admin endpoints, Adds flag to avoid merging add-on line-items

This commit is contained in:
Oliver Windall Juhl authored and GitHub committed 2020-09-23 09:51:47 +02:00
1 parent 34eb53f72e
commit d8483cd135
14 files changed
+169 -88

No files matched your search

@@ -8,6 +8,7 @@ export default new mongoose.Schema({
description: { type: String },
thumbnail: { type: String },
is_giftcard: { type: Boolean, default: false },
should_merge: { type: Boolean, default: true },
has_shipping: { type: Boolean, default: false },
// mongoose doesn't allow multi-type validation but this field allows both
+1 -1
View File
@@ -375,7 +375,7 @@ class CartService extends BaseService {
// If content matches one of the line items currently in the cart we can
// simply update the quantity of the existing line item
if (currentItem) {
if (currentItem && validatedLineItem.should_merge) {
const newQuantity = currentItem.quantity + validatedLineItem.quantity
// Confirm inventory
@@ -38,6 +38,7 @@ class LineItemService extends BaseService {
const lineItemSchema = Validator.object({
title: Validator.string().required(),
is_giftcard: Validator.bool().optional(),
should_merge: Validator.bool().optional(),
description: Validator.string()
.allow("")
.optional(),
@@ -110,6 +111,7 @@ class LineItemService extends BaseService {
title: product.title,
description: variant.title,
quantity,
should_merge: true,
thumbnail: product.thumbnail,
content: {
unit_price,
@@ -117,6 +119,7 @@ class LineItemService extends BaseService {
product,
quantity: 1,
},
metadata,
}
if (product.is_giftcard) {