Skip to content

Commit

Permalink
Set currency on cart at creation time (bigcommerce#1941)
Browse files Browse the repository at this point in the history
  • Loading branch information
bookernath authored and kathir-arizon committed Feb 4, 2025
1 parent 2718097 commit df80531
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-numbers-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Set currency on cart at creation time
3 changes: 3 additions & 0 deletions core/client/mutations/create-cart.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getSessionCustomerAccessToken } from '~/auth';
import { getPreferredCurrencyCode } from '~/lib/currency';

import { client } from '..';
import { graphql, VariablesOf } from '../graphql';
Expand All @@ -21,12 +22,14 @@ type LineItems = CreateCartInput['lineItems'];

export const createCart = async (cartItems: LineItems) => {
const customerAccessToken = await getSessionCustomerAccessToken();
const currencyCode = await getPreferredCurrencyCode();

return await client.fetch({
document: CreateCartMutation,
variables: {
createCartInput: {
lineItems: cartItems,
currencyCode,
},
},
customerAccessToken,
Expand Down

0 comments on commit df80531

Please sign in to comment.