export const addProductLabels = productLabels => {
   window.CouponsPlus.products.labels = {
        ...CouponsPlus.products.labels,
        ...productLabels
    };
}

export const getProductNameById = productId => {
    return window.CouponsPlus.products.labels[productId] || productId;
}

export const addProductsWithIds = idsWithVariations => {
    for (let {id, variationIDs} of idsWithVariations.slice()) {
       window.CouponsPlus.products.idsWithVariations = {
            ...(Array.isArray(CouponsPlus.products.idsWithVariations)? {} :window.CouponsPlus.products.idsWithVariations),
            ...{[id]: variationIDs}
        };
    }
}

export const getVariationIdsFromProductIds = productId => {
    return window.CouponsPlus.products.idsWithVariations[productId] || [];
}

