These are chat archives for reactioncommerce/reaction

17th
Jul 2017
Flavio H Freitas
@flaviohenriquecbc
Jul 17 2017 14:32
hey, people! I just wrote an article about the new features of Javascript, ES8. Take a look and tell me what you think ;)
https://medium.com/@flaviohfreitas/es8-the-new-features-of-javascript-7506210a1a22
🍌 Stephen Keep 🍌
@stephenkeep_twitter
Jul 17 2017 15:28
Hi all, is it possible that a call center worker could use reaction commerce to complete an order on behalf of a customer?
🍌 Stephen Keep 🍌
@stephenkeep_twitter
Jul 17 2017 15:34
it looks like you can create a cart for another user
Meteor.call("cart/createCart", createForUserId);
Aaron Judd
@aaronjudd
Jul 17 2017 16:04
@stephenkeep_twitter that’s not possible out of the box, but yes, that method will create a cart, but there is more to it, we’d need a way to either switch user or to have the some users have permissions to use other userId in their local cart (ie, let admin choose who the user is when checking out)
@AaronLester I think we mention the requirements in deployment docs, not in installation docs, but you’re right, it’d be a good idea @machikoyasuda - we could just add to the requirements section
Aaron Judd
@aaronjudd
Jul 17 2017 16:09
Janus Reith
@janus-reith
Jul 17 2017 17:00
Is there someone here more advanced with schemas?
Im trying to add fields to the ProductVariant schema in my plugin, without editing the original file
The docs have some info regarding this, but they leave some questions open
ereyes97
@ereyes97
Jul 17 2017 19:19

@janus-reith
I am doing the same but I am stuck . If someone could help us ... I am trying to overwrite the ProductVariant schema with some extra fields and others removed... But I want to go step by step. I just Copied the same ProductVariant schema on my plugin and just added a 'test' field to the ProductVariant schema with a default value but when I add products the new field test does not save on mongo... probrably I am not overwriting the schema correctly.

My code :
https://gitlab.com/ereyes/rciweeks

Janus Reith
@janus-reith
Jul 17 2017 22:04
I think I found out how to apply new fields to it, but somehow it still fails to match them if I try to edit them in the variant edit field
But I can see that it works somehow, as new default values etc are considered when i create a new variant
Janus Reith
@janus-reith
Jul 17 2017 22:10
@ereyes97 I took a look at your code:
  1. Your client foder is named "cliente" ?
  2. You need to import the products.js both in client and server
ereyes97
@ereyes97
Jul 17 2017 22:13
@janus-reith
thanks Janus you are rigth!! I will try it ...
Janus Reith
@janus-reith
Jul 17 2017 22:13
  1. Products.attachSchema(ProductVariantSchema, {replace: true}) is probably not the intened behaviour, as a) You dont want to apply the new Schema to all Products but just variants, and b) you want to enhance the existing one, not replace it.
    Use Products.attachSchema(ProductVariantSchema, {selector: {type: 'variant'}});
  1. In your case you dont have to copy over all the fields you have there, just define the new ones.
  • 3 *4

Your products.js should probably look like this:

import { Products } from "/lib/collections";

export const yourEnhancedScheme = new SimpleSchema({
test: {
label: "test",
type: String,
optional: true,
defaultValue: 'test';
}
});

Products.attachSchema(yourEnhancedScheme, {selector: {type: 'variant'}});

Janus Reith
@janus-reith
Jul 17 2017 22:19
Oh I just saw that you wrote you also want to remove others, then you might need to replace
ereyes97
@ereyes97
Jul 17 2017 23:48

@janus-reith
Thanks for your suggestions Janus. Yes, I want to removed fields too. Actually I am planning to do a booking system for hotel reservations... The schemas will be totally diferents. I just begining doing testing and learning about rc code.

"3. Products.attachSchema(ProductVariantSchema, {replace: true}) is probably not the intened behaviour, as a) You dont want to apply the new Schema to all Products but just variants, and b) you want to enhance the existing one, not replace it.
Use Products.attachSchema(ProductVariantSchema, {selector: {type: 'variant'}});"

You mean that a product can have different types of variants?

I import products in index.js on the server and client...
import '../lib/collections/schemas/products'

Now I have another error:

=> Exited with code: 1
23:35:13.209Z INFO Reaction: Load default data from /private/data/
23:35:13.867Z WARN Reaction: Error while importing to Products: Cannot update 'price.max' and 'price' at the same time
23:35:13.923Z INFO Reaction: JobServer started
23:35:13.959Z WARN Reaction: Skipped loading settings from reaction.json.
23:35:26.571Z INFO Reaction: Reaction Version: 1.3.0

/home/eduardo/.meteor/packages/meteor-tool/.1.5.0.utbu0o++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
throw(ex);
^
Error: Match error: Failed Match.OneOf, Match.Maybe or Match.Optional validation
at exports.check (packages/check.js:56:15)
at _registerInventory (imports/plugins/included/inventory/server/methods/inventory.js:16:3)
at imports/plugins/included/inventory/server/startup/init.js:12:21
at server/api/hooks.js:60:1
at Array.reduce (native)
at Object.Hooks.Events.run (server/api/hooks.js:60:1)
at Object.init (server/api/core/core.js:45:18)
at server/startup/init.js:15:2
at server/startup/index.js:18:2
at server/main.js:8:2
at Function.time (/home/eduardo/projectsfiles/reaction/.meteor/local/build/programs/server/profile.js:309:28)
at /home/eduardo/projectsfiles/reaction/.meteor/local/build/programs/server/boot.js:347:13
at /home/eduardo/projectsfiles/reaction/.meteor/local/build/programs/server/boot.js:388:5
at Function.run (/home/eduardo/projectsfiles/reaction/.meteor/local/build/programs/server/profile.js:510:12)
at /home/eduardo/projectsfiles/reaction/.meteor/local/build/programs/server/boot.js:386:11
=> Exited with code: 1
23:35:53.899Z INFO Reaction: Load default data from /private/data/
23:35:54.549Z WARN Reaction: Error while importing to Products: Cannot update 'price.max' and 'price' at the same time
23:35:54.569Z INFO Reaction: JobServer started
23:35:54.590Z WARN Reaction: Skipped loading settings from reaction.json.

Any Idea ?

ereyes97
@ereyes97
Jul 17 2017 23:56
@zenweasel
Hello Brent
Yes, but I just add a new field
test: {
label: "test",
type: String,
optional: true,
defaultValue: 'test'
},
Should I change the data for an optional field and with default value?
Brent Hoover
@zenweasel
Jul 17 2017 23:57
No, but this error would lead me to believe you are modifying both price and price.max in your import file:
23:35:13.867Z WARN Reaction: Error while importing to Products: Cannot update 'price.max' and 'price' at the same time
where price is an object that contains price.max
Brent Hoover
@zenweasel
Jul 17 2017 23:59
the error would appear to be in your Products.json
ereyes97
@ereyes97
Jul 17 2017 23:59
ok, let me check