diff --git a/imports/plugins/included/inventory/server/hooks/hooks.js b/imports/plugins/included/inventory/server/hooks/hooks.js index 684881c5fdc..c5b896f0956 100644 --- a/imports/plugins/included/inventory/server/hooks/hooks.js +++ b/imports/plugins/included/inventory/server/hooks/hooks.js @@ -102,6 +102,7 @@ function markInventoryShipped(doc) { shopId: orderItem.shopId, quantity: orderItem.quantity, productId: orderItem.productId, + product: orderItem.product, variants: orderItem.variants, title: orderItem.title }; @@ -120,6 +121,7 @@ function markInventorySold(doc) { shopId: orderItem.shopId, quantity: orderItem.quantity, productId: orderItem.productId, + product: orderItem.product, variants: orderItem.variants, title: orderItem.title }; diff --git a/lib/collections/schemas/cart.js b/lib/collections/schemas/cart.js index 9e464cde418..c39b9b4eebd 100644 --- a/lib/collections/schemas/cart.js +++ b/lib/collections/schemas/cart.js @@ -1,7 +1,7 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { shopIdAutoValue } from "./helpers"; import { Payment } from "./payments"; -import { ProductVariant } from "./products"; +import { Product, ProductVariant } from "./products"; import { Shipment, ShippingParcel } from "./shipping"; import { Workflow } from "./workflow"; @@ -29,6 +29,9 @@ export const CartItem = new SimpleSchema({ type: Number, min: 0 }, + product: { + type: Product + }, variants: { type: ProductVariant }, diff --git a/server/imports/fixtures/cart.js b/server/imports/fixtures/cart.js index 1a8341822ed..9251b74e774 100755 --- a/server/imports/fixtures/cart.js +++ b/server/imports/fixtures/cart.js @@ -31,6 +31,7 @@ export function getCartItem(options = {}) { productId: product._id, shopId: getShop()._id, quantity: _.random(1, selectedOption.inventoryQuantity), + product: product, variants: selectedOption, title: product.title }; @@ -53,6 +54,7 @@ export function createCart(productId, variantId) { productId: product._id, shopId: getShop()._id, quantity: 1, + product: product, variants: variant, title: product.title }; diff --git a/server/imports/fixtures/orders.js b/server/imports/fixtures/orders.js index f8996262fa8..c6cda497776 100755 --- a/server/imports/fixtures/orders.js +++ b/server/imports/fixtures/orders.js @@ -109,6 +109,7 @@ export default function () { shopId: product.shopId, productId: product._id, quantity: 1, + product: product, variants: selectedOption, workflow: { status: "new" @@ -119,6 +120,7 @@ export default function () { shopId: product2.shopId, productId: product2._id, quantity: 1, + product: product2, variants: selectedOption2, workflow: { status: "new" diff --git a/server/methods/core/cart.js b/server/methods/core/cart.js index 6681fcf2f7b..ee293d293a2 100644 --- a/server/methods/core/cart.js +++ b/server/methods/core/cart.js @@ -366,6 +366,7 @@ Meteor.methods({ if (cartVariantExists) { return Collections.Cart.update({ "_id": cart._id, + "items.product._id": productId, "items.variants._id": variantId }, { $inc: { @@ -402,6 +403,7 @@ Meteor.methods({ shopId: product.shopId, productId: productId, quantity: quantity, + product: product, variants: variant, title: product.title, type: product.type, @@ -477,6 +479,8 @@ Meteor.methods({ _id: itemId } } + }, { + getAutoValues: false // See https://github.com/aldeed/meteor-collection2/issues/245 }, (error, result) => { if (error) { Logger.error(error);