something for everyone
// If use have the URL discount code: willDiscountCode=**, update the cart data for use discount code
try {
const urlParams = new URLSearchParams(window.location.search)
const willDiscountCode = urlParams.get("willDiscountCode")
if (willDiscountCode) {
fetch("/cart/update.js", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
discount: willDiscountCode,
}),
})
}
} catch (error) {
// Error handling for discount code update
}