MED-197: improve analysis compare page
This commit is contained in:
@@ -7,6 +7,8 @@ import { sdk } from '@lib/config';
|
||||
import medusaError from '@lib/util/medusa-error';
|
||||
import { HttpTypes, StoreCart } from '@medusajs/types';
|
||||
|
||||
import { getLogger } from '@kit/shared/logger';
|
||||
|
||||
import {
|
||||
getAuthHeaders,
|
||||
getCacheOptions,
|
||||
@@ -135,13 +137,21 @@ export async function addToCart({
|
||||
quantity: number;
|
||||
countryCode: string;
|
||||
}) {
|
||||
const logger = await getLogger();
|
||||
const ctx = {
|
||||
variantId,
|
||||
quantity,
|
||||
countryCode,
|
||||
};
|
||||
if (!variantId) {
|
||||
logger.error(ctx, 'Missing variant ID when adding to cart');
|
||||
throw new Error('Missing variant ID when adding to cart');
|
||||
}
|
||||
|
||||
const cart = await getOrSetCart(countryCode);
|
||||
|
||||
if (!cart) {
|
||||
logger.error(ctx, 'Error retrieving or creating cart');
|
||||
throw new Error('Error retrieving or creating cart');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user