Skip to content

Commit

Permalink
LYNX-755: Error when requesting segments for non-default store (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
sivaschenko authored Feb 11, 2025
1 parent b8813cf commit 717a00d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion blocks/targeted-block/qraphql.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { fetchGraphQl } from '@dropins/tools/fetch-graphql.js';
import { fetchGraphQl, setFetchGraphQlHeaders } from '@dropins/tools/fetch-graphql.js';
import { getHeaders } from '../../scripts/configs.js';

export const getActiveRules = async (cartId) => {
try {
setFetchGraphQlHeaders(await getHeaders('cart'));
const response = await fetchGraphQl(
`query CUSTOMER_SEGMENTS($cartId: String!){
customerSegments(cartId: $cartId) {
Expand Down Expand Up @@ -46,6 +48,7 @@ export const getCatalogPriceRules = async (sku) => {
}
}
`;
setFetchGraphQlHeaders(await getHeaders('cart'));
const response = await fetchGraphQl(
query,
{
Expand Down
1 change: 1 addition & 0 deletions blocks/targeted-block/targeted-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const updateTargetedBlocksVisibility = async () => {
cart: {
rules: [],
},
catalogPriceRules: [],
} : await getActiveRules(Cart.getCartDataFromCache().id);

// eslint-disable-next-line no-underscore-dangle
Expand Down

0 comments on commit 717a00d

Please sign in to comment.