Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
refactor(collection & search result): enabled locale based prices (#330)
Browse files Browse the repository at this point in the history
* feat: multi currency

* feat: multi-currency feature

* feat: added multicurrency feature (static)

* feat: pdp: multi currency

* feat: muti-currency refactor

* chore: version upgrade

* feat: added feature to update userfields

* fix: fixed selected variantby options

* fix: cartgetters item price

* refactor: getproducts api method

* fix: login modal popup error

* feat: display discount on cart drawer

* chore: updated shopify version

* chore: remove wishlist function for now (#213)

Co-authored-by: Jeff Paltera <[email protected]>

* fix: incosistent footer (#214)

* chore: update the misaligned margin of components (#215)

* chore: update home padding

* chore: updated margin on whole

* chore: updated margin on whole

* feat: display discount on cart drawer (#230)

* feat: multi currency

* feat: multi-currency feature

* feat: added multicurrency feature (static)

* feat: pdp: multi currency

* feat: muti-currency refactor

* chore: version upgrade

* feat: added feature to update userfields

* fix: fixed selected variantby options

* fix: cartgetters item price

* refactor: getproducts api method

* chore: remove wishlist function for now (#213)

Co-authored-by: Jeff Paltera <[email protected]>

* fix: incosistent footer (#214)

* chore: update the misaligned margin of components (#215)

* chore: update home padding

* chore: updated margin on whole

* chore: updated margin on whole

* fix: login modal popup error

* feat: display discount on cart drawer

* chore: updated shopify version

Co-authored-by: Jeff Paltera <[email protected]>
Co-authored-by: Jeff Paltera <[email protected]>

* fix: ssr for crawlers for multilingual

* fix: version upgraded

* refactor: added function for detect country

* fix: ssr for crawlers for multilingual (#231)

* feat: multi currency

* feat: multi-currency feature

* feat: added multicurrency feature (static)

* feat: pdp: multi currency

* feat: muti-currency refactor

* chore: version upgrade

* feat: added feature to update userfields

* fix: fixed selected variantby options

* fix: cartgetters item price

* refactor: getproducts api method

* chore: remove wishlist function for now (#213)

Co-authored-by: Jeff Paltera <[email protected]>

* fix: incosistent footer (#214)

* chore: update the misaligned margin of components (#215)

* chore: update home padding

* chore: updated margin on whole

* chore: updated margin on whole

* fix: login modal popup error

* feat: display discount on cart drawer

* chore: updated shopify version

* fix: ssr for crawlers for multilingual

* fix: version upgraded

* refactor: added function for detect country

Co-authored-by: Jeff Paltera <[email protected]>
Co-authored-by: Jeff Paltera <[email protected]>

* chore: add #TechForUkraine

* Update README.md

* feat(cartdrawer): coupon add/remove feature

* feat(cartdrawer): coupon add/remove feature

* fix: suggested changes

* refactor: remove shopify buy deps from createcart & checkout

* refactor: removed shopify buy deps from updatecart

* fix: resolved linter error

* refactor: suggeted changes

* refactor: suggeted changes

* refactor: refactored get country method for getproduct

* refactor: implemented suggested changes

* refactor: implemented suggested changes

* refactor: pdp: related products- disabled add to cart for out of stock products

* refactor: removed any from default query

* fix(PDP): add to cart not working on match with it section

* chore: updated sfui to 0.12.x

* refactor: removed context as param from setup method

* chore: upgraded SFUI to 0.12.3

* fix: updated yarn.lock

* fix: updated currency to EUR in nuxt.config.js

* refactor: added observer for section rendering

* refactor(sign in): removed shopify buy deps from signin api

* refactor(sign out): removed shopify buy deps from sign out api

* fix: resolved conflicts

* refactor: removed shopify buy sdk deps from signup

* refactor: removed shopify buy sdk deps from forgotpassword api method

* refactor: removed shopify buy sdk deps from change password api method

* refactor(collection & search result): enabled locale based prices

Co-authored-by: Jeff Paltera <[email protected]>
Co-authored-by: Jeff Paltera <[email protected]>
Co-authored-by: Heitor Ramon Ribeiro <[email protected]>
  • Loading branch information
4 people authored Apr 12, 2022
1 parent f7b5ced commit e37048d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
9 changes: 5 additions & 4 deletions packages/apollo/src/api/getCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { gql } from '@apollo/client/core'
import { ShopifyApolloContext } from '../library'
import { QueryRoot, QueryRootCollectionArgs, ProductFilter } from '../shopify'
import { mapFacetToProductFilter } from '../helpers/mapFacetToProductFilter'
import { getCountry } from '../helpers'

const collectionQuery = gql`
query collection($handle: String, $first: Int, $filters: [ProductFilter!]) {
const collectionQuery = gql`query collection($handle: String, $first: Int, $filters: [ProductFilter!], $country: CountryCode!) @inContext(country: $country ){
collection(handle: $handle) {
id
handle
Expand Down Expand Up @@ -81,9 +81,10 @@ export default async function getCollection(context: ShopifyApolloContext, { cat
const variables = {
handle: categorySlug,
first: itemsPerPage ?? 5,
filters: mapFacetToProductFilter(filters)
filters: mapFacetToProductFilter(filters),
country: getCountry(context)
}

const { collection } = context.extendQuery(
customQuery,
{
Expand Down
4 changes: 3 additions & 1 deletion packages/apollo/src/api/searchProduct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { CustomQuery, ProductsSearchParams } from '@vue-storefront/core'
import { ShopifyApolloContext } from '../library'
import { QueryRoot, QueryRootProductsArgs } from '../shopify'
import { SearchProductQuery } from '../query/SearchProduct.gql'
import { getCountry } from '../helpers'

export async function searchProduct(context: ShopifyApolloContext, params: ProductsSearchParams, customQuery?: CustomQuery) {
const variables = {
query: params.term,
first: params.perPage ?? 5
first: params.perPage ?? 5,
country: getCountry(context)
}

const { products } = context.extendQuery(
Expand Down
6 changes: 6 additions & 0 deletions packages/apollo/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const getCountry = (context, isProduct = false, defaultLocale = 'en', curLocale = 'en') => {
if (isProduct) {
return curLocale === "en" ? (defaultLocale).toUpperCase() : (curLocale).toUpperCase();
}
return context.res.req.cookies['vsf-locale'] ? context.res.req.cookies['vsf-locale'] === "en" ? "US" : (context.res.req.cookies['vsf-locale']).toUpperCase() : "US";
}
5 changes: 3 additions & 2 deletions packages/apollo/src/query/SearchProduct.gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { gql } from "@apollo/client/core";
export const SearchProductQuery = gql`
query products(
$first: Int,
$query: String
) {
$query: String,
$country: CountryCode!
) @inContext(country: $country) {
products(first: $first, query: $query) {
edges {
node {
Expand Down

0 comments on commit e37048d

Please sign in to comment.