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

Commit

Permalink
refactor: usecart methods (createcart & checkout) adjustments (#246)
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 <jpaltera@vuestorefront.io>

* 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 <jpaltera@vuestorefront.io>

* 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 <jeffpaltera@gmail.com>
Co-authored-by: Jeff Paltera <jpaltera@vuestorefront.io>

* 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 <jpaltera@vuestorefront.io>

* 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 <jeffpaltera@gmail.com>
Co-authored-by: Jeff Paltera <jpaltera@vuestorefront.io>

* 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

Co-authored-by: Jeff Paltera <jeffpaltera@gmail.com>
Co-authored-by: Jeff Paltera <jpaltera@vuestorefront.io>
Co-authored-by: Heitor Ramon Ribeiro <heitor.ramon@gmail.com>
  • Loading branch information
4 people committed Apr 1, 2022
1 parent fbd6767 commit 3f492c9
Show file tree
Hide file tree
Showing 5 changed files with 17,841 additions and 36 deletions.
11 changes: 0 additions & 11 deletions packages/api-client/src/api/createCart/defaultMutation.ts

This file was deleted.

46 changes: 35 additions & 11 deletions packages/api-client/src/api/createCart/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { CustomQuery } from '@vue-storefront/core';
import { checkoutMutation as mutation } from './../checkoutMutations/buildMutations';
import { gql } from '@apollo/client/core'
import { getCountry } from '../../helpers/utils'

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function createCart(context, _params, _customQuery?: CustomQuery) {
const data = {
"input": {

const DEFAULT_MUTATION = gql`mutation checkoutCreate($input: CheckoutCreateInput!) {
checkoutCreate(input:$input){
checkout{
id
webUrl
}
checkoutUserErrors {
code
field
message
}
}
}`

const payload = {
input: {
buyerIdentity: {
countryCode: (context.res.req.cookies['vsf-locale'] === "en") ? "US" : (context.res.req.cookies['vsf-locale']).toUpperCase()
countryCode: getCountry(context)
}
}
}
// initiate the cart
return await context.client.graphQLClient.send(mutation(context), data).then(({ data }) => {
if (data) {
return data.checkoutCreate.checkout.id;
}

const { checkoutCreate } = context.extendQuery(
_customQuery,
{
checkoutCreate: {
mutation: DEFAULT_MUTATION,
payload
}
}
)
return await context.client.apolloClient.mutate({
mutation: checkoutCreate.mutation,
variables: checkoutCreate.payload
}).then((result) => {
return result.data.checkoutCreate.checkout;
});
}
12 changes: 0 additions & 12 deletions packages/api-client/src/api/updateCart/defaultMutation.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/composables/src/useCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const params: UseCartFactoryParams<Cart, CartItem, Product> = {
if ((existngCartId === undefined || existngCartId === '' || isLocaleSwitched)) {
// Initiate new cart
existngCartId = await context.$shopify.api.createCart().then((checkout) => {
context.$shopify.config.app.$cookies.set(appKey + '_cart_id', checkout, {maxAge: 60 * 60 * 24 * 365, path: '/'});
return checkout;
context.$shopify.config.app.$cookies.set(appKey + '_cart_id', checkout.id, {maxAge: 60 * 60 * 24 * 365, path: '/'});
return checkout.id;
});
}
const checkoutId = existngCartId;
Expand Down
Loading

0 comments on commit 3f492c9

Please sign in to comment.