Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cart schema to include all product data #2610

Merged
merged 8 commits into from
Aug 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions imports/plugins/included/inventory/server/hooks/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -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
};
Expand Down
5 changes: 4 additions & 1 deletion lib/collections/schemas/cart.js
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -29,6 +29,9 @@ export const CartItem = new SimpleSchema({
type: Number,
min: 0
},
product: {
type: Product
},
variants: {
type: ProductVariant
},
Expand Down
2 changes: 2 additions & 0 deletions server/imports/fixtures/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -53,6 +54,7 @@ export function createCart(productId, variantId) {
productId: product._id,
shopId: getShop()._id,
quantity: 1,
product: product,
variants: variant,
title: product.title
};
Expand Down
2 changes: 2 additions & 0 deletions server/imports/fixtures/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default function () {
shopId: product.shopId,
productId: product._id,
quantity: 1,
product: product,
variants: selectedOption,
workflow: {
status: "new"
Expand All @@ -119,6 +120,7 @@ export default function () {
shopId: product2.shopId,
productId: product2._id,
quantity: 1,
product: product2,
variants: selectedOption2,
workflow: {
status: "new"
Expand Down
4 changes: 4 additions & 0 deletions server/methods/core/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ Meteor.methods({
if (cartVariantExists) {
return Collections.Cart.update({
"_id": cart._id,
"items.product._id": productId,
"items.variants._id": variantId
}, {
$inc: {
Expand Down Expand Up @@ -402,6 +403,7 @@ Meteor.methods({
shopId: product.shopId,
productId: productId,
quantity: quantity,
product: product,
variants: variant,
title: product.title,
type: product.type,
Expand Down Expand Up @@ -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);
Expand Down