diff --git a/solutions/scripts/utils/utils.js b/solutions/scripts/utils/utils.js index dc350c097..ca964eb0e 100644 --- a/solutions/scripts/utils/utils.js +++ b/solutions/scripts/utils/utils.js @@ -1,3 +1,5 @@ +import { getMetadata } from './aem.js'; + const cacheResponse = new Map(); const FETCH_URL = 'https://www.bitdefender.com.au/site/Store/ajax'; @@ -50,11 +52,16 @@ async function findProductVariant(cachedResponse, variant) { */ export async function fetchProduct(code = 'av', variant = '1u-1y', pid = null) { const data = new FormData(); + let pidFromUrl; + let pidFromMetadata; // extract pid from url if (!pid) { const url = new URL(window.location.href); - // eslint-disable-next-line no-param-reassign - pid = url.searchParams.get('pid'); + pidFromUrl = url.searchParams.get('pid'); + } + + if (!pidFromUrl) { + pidFromMetadata = getMetadata('pid'); } data.append('data', JSON.stringify({ @@ -62,7 +69,7 @@ export async function fetchProduct(code = 'av', variant = '1u-1y', pid = null) { product_id: code, config: { extra_params: { - pid, + pid: pidFromUrl || pidFromMetadata, }, }, }));