diff --git a/assets/js/modules/cart.js b/assets/js/modules/cart.js index e290880..9550093 100644 --- a/assets/js/modules/cart.js +++ b/assets/js/modules/cart.js @@ -18,7 +18,7 @@ export async function sync() { let ids = items.map(obj => obj.id); if (ids.length > 0) { - let products = await fetch(url("contents/" + ids.join(","))); + let products = await fetch(url("/contents/" + ids.join(","))); products = await products.json(); products.contents.forEach(product => { @@ -93,5 +93,6 @@ export async function getTotalPrice() { export async function getLink() { await sync(); - return url(btoa(JSON.stringify(items))); + let miniItems = items.map(obj => { return { id: obj.id, quantity: obj.quantity } }); + return url("/?cart=" + btoa(JSON.stringify(miniItems))); } \ No newline at end of file diff --git a/assets/js/utils.js b/assets/js/utils.js index 64cb1df..e172cd1 100644 --- a/assets/js/utils.js +++ b/assets/js/utils.js @@ -16,7 +16,7 @@ export function isEncoded(string) { } export function url(path = "") { - const baseUrlElement = document.getElementById("base-url"); + const baseUrlElement = document.querySelector('meta[name="url-base"]'); const baseUrl = baseUrlElement ? baseUrlElement.getAttribute("content") : ""; return baseUrl + path; } \ No newline at end of file