Kentucky Derby – Apparel, Decor & Party Essentials
Get Derby-ready with our Kentucky Derby collection! From stylish apparel and hats to party supplies and official merchandise, this collection has everything you need to celebrate the greatest two minutes in sports in true Kentucky style.
Choosing a selection results in a full page refresh.
Opens in a new window.
document.addEventListener("DOMContentLoaded", function () {
console.log("Free Gift Script loaded successfully!");
// Free Gift Variant ID
const FREE_GIFT_VARIANT_ID = "43792888627244"; // Replace with your free gift's Variant ID
const PROMO_END_DATE = new Date("2025-10-05T23:59:59Z"); // Set the promotion end date
// Function to check the cart and apply the free gift logic
function checkCartForFreeGift() {
console.log("Checking cart for free gift...");
fetch("/cart.js")
.then((response) => response.json())
.then((cart) => {
console.log("Cart data fetched:", cart);
const subtotal = cart.items_subtotal_price / 100; // Convert to dollars
console.log("Cart subtotal:", subtotal);
const hasFreeGift = cart.items.some(
(item) => item.variant_id === parseInt(FREE_GIFT_VARIANT_ID)
);
console.log("Does the cart already have the free gift?", hasFreeGift);
// Check if the promotion is still active
if (new Date() > PROMO_END_DATE) {
console.log("Promotion has ended.");
if (hasFreeGift) {
removeFreeGift();
}
return;
}
// Add or remove the free gift based on the subtotal
if (subtotal >= 50 && !hasFreeGift) {
console.log("Adding free gift...");
addFreeGift();
} else if (subtotal < 50 && hasFreeGift) {
console.log("Removing free gift...");
removeFreeGift();
} else {
console.log("No action needed.");
}
})
.catch((error) => {
console.error("Error fetching cart data:", error);
});
}
// Function to add the free gift
function addFreeGift() {
fetch("/cart/add.js", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
id: FREE_GIFT_VARIANT_ID, // Use the Variant ID here
quantity: 1,
}),
})
.then((response) => {
if (response.ok) {
console.log("Free gift added successfully!");
} else {
console.error("Failed to add free gift:", response);
}
})
.catch((error) => {
console.error("Error adding free gift:", error);
});
}
// Function to remove the free gift
function removeFreeGift() {
fetch("/cart.js")
.then((response) => response.json())
.then((cart) => {
const lineItem = cart.items.find(
(item) => item.variant_id === parseInt(FREE_GIFT_VARIANT_ID)
);
if (lineItem) {
fetch("/cart/change.js", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
line: lineItem.key, // Use the line item key to remove it
quantity: 0,
}),
})
.then((response) => {
if (response.ok) {
console.log("Free gift removed successfully!");
} else {
console.error("Failed to remove free gift:", response);
}
})
.catch((error) => {
console.error("Error removing free gift:", error);
});
}
})
.catch((error) => {
console.error("Error fetching cart data for removal:", error);
});
}
// Run the check on page load and cart updates
checkCartForFreeGift();
document.addEventListener("cart:updated", checkCartForFreeGift);
});