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 product scheme to set country autovalue #2840

Merged
merged 21 commits into from
Sep 22, 2017

Conversation

kieckhafer
Copy link
Member

@kieckhafer kieckhafer commented Sep 12, 2017

Update our product schema to set default origin country for Product and Variant.

Default country is country the shop address is based in.

@kieckhafer kieckhafer requested review from brent-hoover and removed request for aaronjudd September 12, 2017 23:59

/**
* shopDefaulCountry
* @summary used for schema injection autoValue
Copy link
Contributor

Choose a reason for hiding this comment

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

I hadn't seen @summary or @example used before - would you mind adding those to the ongoing discussion in docs? reactioncommerce/reaction-docs#275

Copy link
Contributor

Choose a reason for hiding this comment

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

shopDefaultCountry - minor typo!

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.
Would like to see a little more inline comments and if you know of any other way to identify a Shop's primary address let's consider that, otherwise I'll 👍

* @return {String} returns country value from default shop
*/
export function shopDefaultCountry() {
if (this.isSet && Meteor.isServer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I can read through this, but I think it's probably worth adding a little more inline commentary as to what's going on for people who are less versed in how autoValue works.

const shop = Shops.findOne({
_id: Reaction.getShopId()
});
if (shop && shop.addressBook && shop.addressBook[0]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love that we're assuming that the 0th address is the correct address here, but I know that's a pattern that's older than this PR.

Is there an indicator that a shop is using a specific address as their "shop address" similar to how customers can have a default address? Is it the default flag? Or any other way to identify the Shop's main address?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't believe there is any way to determine the default address, and calling on the [0] is the way to do it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, there's a field on the schema that determines this.

  isBillingDefault: {
    label: "Make this your default billing address?",
    type: Boolean
  },
  isShippingDefault: {
    label: "Make this your default shipping address?",
    type: Boolean
  },

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we not use that for Shops?

Copy link
Collaborator

@brent-hoover brent-hoover Sep 14, 2017

Choose a reason for hiding this comment

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

I see that it's currently set to True on one created shop. Even if we don't set it for now this feels like a more "future-proof" way of doing it.

Copy link
Member Author

Choose a reason for hiding this comment

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

^^ yeah... dunno why I didn't connect that, will update to use... one of the two. Which should be used for this? Shipping?

This is for the product origin.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think Shipping makes the most sense. That where you would have things shipped to is there you want to ship from. At least in most cases and as accurate as being the right country.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So we do set it explicitly in the dashboard so I think that's the way to go. Maybe we could add a note there that says setting that will set the default origin for Products? It's probably an autoform so not sure how hard that would be.

reaction

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.

Use default address field on shop address to ascertain the shop address.

});

// Find the current shops primary address
if (shop && shop.addressBook && shop.addressBook[0]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how much work this would really be, but why we don't extend this a little more, with the goal of removing [0] dependencies, and remove the need refactor this again (so soon)? One approach that seems easy, could be to just set and check isShippingDefault to know the origination country?

Copy link
Contributor

@aaronjudd aaronjudd left a comment

Choose a reason for hiding this comment

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

Review approaches that remove [0]

@kieckhafer
Copy link
Member Author

kieckhafer commented Sep 15, 2017

@aaronjudd @zenweasel my latest update should take care of getting rid of using [0]

@aaronjudd
Copy link
Contributor

Tests are failing.

@aaronjudd
Copy link
Contributor

@kieckhafer can you fix conflicts and tests here?

@kieckhafer
Copy link
Member Author

fixed and fixed

@aaronjudd aaronjudd merged commit 0d3a96f into marketplace Sep 22, 2017
@aaronjudd aaronjudd deleted the ek-setDefaultProductOriginCountry branch September 22, 2017 16:13
@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.

5 participants