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

Allow passing country and currency to Product.pricing and ProductVariant.pricing #4315

Closed
patrys opened this issue Jun 19, 2019 · 5 comments · Fixed by #6784
Closed

Allow passing country and currency to Product.pricing and ProductVariant.pricing #4315

patrys opened this issue Jun 19, 2019 · 5 comments · Fixed by #6784
Labels
graphql Issues related to the GraphQL API

Comments

@patrys
Copy link
Member

patrys commented Jun 19, 2019

What I'm trying to achieve

We need to allow people to explicitly switch countries and have the correct prices displayed.

Current implementation relies on request.country but when using the GraphQL API it's always set to whatever GeoIP returned.

Describe a proposed solution

Currently, the API looks like this:

type Product {
  pricing: ProductPricingInfo
}

type ProductVariant {
  pricing: VariantPricingInfo
}

type ProductPricingInfo {
  available: Boolean
    @deprecated(
      reason: "This has been moved to the parent type as 'is_available'."
    )
  onSale: Boolean
  discount: TaxedMoney
  discountLocalCurrency: TaxedMoney
  priceRange: TaxedMoneyRange
  priceRangeUndiscounted: TaxedMoneyRange
  priceRangeLocalCurrency: TaxedMoneyRange
}

type VariantPricingInfo {
  available: Boolean
    @deprecated(
      reason: "This has been moved to the parent type as 'is_available'."
    )
  onSale: Boolean
  discount: TaxedMoney
  discountLocalCurrency: TaxedMoney
  price: TaxedMoney
  priceUndiscounted: TaxedMoney
  priceLocalCurrency: TaxedMoney
}

type TaxedMoney {
  currency: String!
  gross: Money!
  net: Money!
  tax: Money!
}

type Money {
  currency: String!
  amount: Float!
  localized: String!
}

I propose that we allow country and currency to be passed explicitly and that we drop the Money.localized field:

type Product {
  pricing(country: CountryCode, currency: String): ProductPricingInfo
}

type ProductVariant {
  pricing(country: CountryCode, currency: String): VariantPricingInfo
}

type Money {
  currency: String!
  amount: Float!
}

If a value is not given, use the store's default country or currency (instead of falling back to GeoIP).

If a currency is given, return values in that currency (using the currency exchange rates) or return null if unable to do so.

If a country is given, calculate taxes according to that country's tax regulations.

@patrys patrys added the graphql Issues related to the GraphQL API label Jun 19, 2019
@krzysztofwolski
Copy link
Member

Will it affect product filtering? How to filter products by price without knowing taxes?

@patrys
Copy link
Member Author

patrys commented Jun 19, 2019

We've talked about this, ideally passing country and currency should be possible at products level if we ever want to allow products to be filtered or sorted with regard to local taxes or a non-standard currency.

@stale
Copy link

stale bot commented Nov 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 1, 2019
@stale
Copy link

stale bot commented Jan 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 11, 2020
@maarcingebala
Copy link
Member

Queries are one thing; the other is that we need to know the country in checkout mutations that check the stock quantity so that we can pick the right warehouse. We need to get rid of usages of request.country (or info.context.country in API) and instead have a country code explicitly provided by the user.

Also, we currently use countries to determine a warehouse, but I think we want to have better granularity and e.g. allow to define warehouses per state (that would be the use case in the US). Does it also affect pricing queries @patrys?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
graphql Issues related to the GraphQL API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants