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

[Marketplace] Adds the ability to set metafields on cart items #2704

Merged
merged 3 commits into from
Aug 21, 2017

Conversation

mikemurray
Copy link
Member

This PR adds the ability to add metafields to a cart item while adding that item to cart. This could be useful to apply additional information to an item added like affiliate tracking or geolocation, etc.

Examples:

Adds metadata to a cart item only once, and does not get updated if the same item is added to the cart again.

const additionalOptions = {
  metafields: [
    { key: "KEY", value: "VALUE" }
  ]
};

Meteor.call("cart/addToCart", "PRODUCT_ID", "VARIANT_ID", QUANTITY, additionalOptions);

Adds metadata to a cart item while adding to cart, and will update every time that item is added to cart.

const additionalOptions = {
  overriteExistingMetafields: true,
  metafields: [
    { key: "KEY", value: "VALUE" }
  ]
};

Meteor.call("cart/addToCart", "PRODUCT_ID", "VARIANT_ID", QUANTITY, additionalOptions);

Final param, additionalOptions is optional.

Meteor.call("cart/addToCart", "PRODUCT_ID", "VARIANT_ID", QUANTITY);


// Copy additionalOptions into an options object to use througout the method
const options = {
overriteExistingMetafields: false, // Allows updating of metafields on quantity change
Copy link
Collaborator

@brent-hoover brent-hoover Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

Copy link
Collaborator

@brent-hoover brent-hoover left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in option name?

@brent-hoover
Copy link
Collaborator

My only concern here is that Metadata not turn into ActualData. We need to not store anything there that the app relies on to do any primary logic, otherwise it should be in the schema.

Copy link
Contributor

@spencern spencern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@mikemurray mikemurray merged commit 91d44f5 into marketplace Aug 21, 2017
@mikemurray mikemurray deleted the mm-cart-item-metafields branch August 21, 2017 20:56
@spencern spencern mentioned this pull request Oct 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants