|
|
@@ -258,6 +258,14 @@ function backendUrl(): string {
|
|
|
|
return value.replace(/\/$/, "");
|
|
|
|
return value.replace(/\/$/, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function regionId(): string {
|
|
|
|
|
|
|
|
const value = process.env.MEDUSA_REGION_ID;
|
|
|
|
|
|
|
|
if (!value) {
|
|
|
|
|
|
|
|
throw new Error("MEDUSA_REGION_ID no está configurado.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function medusaFetch<T>(
|
|
|
|
async function medusaFetch<T>(
|
|
|
|
path: string,
|
|
|
|
path: string,
|
|
|
|
searchParams?: URLSearchParams,
|
|
|
|
searchParams?: URLSearchParams,
|
|
|
@@ -515,7 +523,10 @@ async function fetchProducts(
|
|
|
|
): Promise<Product[]> {
|
|
|
|
): Promise<Product[]> {
|
|
|
|
const params = new URLSearchParams({
|
|
|
|
const params = new URLSearchParams({
|
|
|
|
limit: String(limit),
|
|
|
|
limit: String(limit),
|
|
|
|
currency_code: "cop",
|
|
|
|
// El validador de /store/products no acepta currency_code (400
|
|
|
|
|
|
|
|
// "Unrecognized fields"); el precio calculado solo se resuelve con
|
|
|
|
|
|
|
|
// region_id.
|
|
|
|
|
|
|
|
region_id: regionId(),
|
|
|
|
fields:
|
|
|
|
fields:
|
|
|
|
"+metadata,+images,+tags,+categories,+collection,+variants.inventory_quantity,+variants.calculated_price,+variants.options",
|
|
|
|
"+metadata,+images,+tags,+categories,+collection,+variants.inventory_quantity,+variants.calculated_price,+variants.options",
|
|
|
|
});
|
|
|
|
});
|
|
|
@@ -543,7 +554,10 @@ export const medusaCatalogProvider: CatalogProvider = {
|
|
|
|
const params = new URLSearchParams({
|
|
|
|
const params = new URLSearchParams({
|
|
|
|
handle: slug,
|
|
|
|
handle: slug,
|
|
|
|
limit: "1",
|
|
|
|
limit: "1",
|
|
|
|
currency_code: "cop",
|
|
|
|
// El validador de /store/products no acepta currency_code (400
|
|
|
|
|
|
|
|
// "Unrecognized fields"); el precio calculado solo se resuelve con
|
|
|
|
|
|
|
|
// region_id.
|
|
|
|
|
|
|
|
region_id: regionId(),
|
|
|
|
fields:
|
|
|
|
fields:
|
|
|
|
"+metadata,+images,+tags,+categories,+collection,+variants.inventory_quantity,+variants.calculated_price,+variants.options",
|
|
|
|
"+metadata,+images,+tags,+categories,+collection,+variants.inventory_quantity,+variants.calculated_price,+variants.options",
|
|
|
|
});
|
|
|
|
});
|
|
|
|