Item AGBD8-PC
Regular price $6.99
Sale price $6.99 Regular price reg.
Unit price
/per
Sold out
Product Details
- Each Paint Can Includes Approximately : 8 Milk Chocolate Hershey's Kisses, 8 Dum Dums, 8 Pieces of Salt Water Taffy, 4 Caramel Filled Foil Balls
- Dimensions: Can: 3.5" x 3.75"; Sticker: 3"
- CANDY TYPE/COLOR ARE SUBJECT TO CHANGE DUE TO AVAILABILITY
- This item is heat sensitive and will ship with cool pack packaging as needed
You Pay:
$6.99
Couldn't load pickup availability
`; } } } let persDefault = ""; const productSku = 'AGBD8-3C'; document.addEventListener('click', (event) => { if (event.target.classList.contains('variant-picker__option-button--color') || ( event.target.nextElementSibling && event.target.nextElementSibling.classList.contains('variant-picker__option-button--color'))) { const checkedColor = event.target.closest('.variant-picker__option').querySelector('input'); if (variantBackgrounds && Object.values(variantBackgrounds).length > 0) { persDefault = variantBackgrounds[checkedColor.value]; } setTimeout(function() { addVariantPrices(); }, 1000) } else if (event.target.classList.contains('variant-picker__option-button') || ( event.target.nextElementSibling && event.target.nextElementSibling.classList.contains('variant-picker__option-button--button'))) { setTimeout(function() { addVariantPrices(); }, 1000) } }) document.addEventListener('DOMContentLoaded', function () { setTimeout(function() { addVariantPrices(); }, 1500) const colorOptions = document.querySelectorAll('.variant-picker__option-button--color'); if (Array.from(colorOptions).length > 0) { colorOptions.forEach((colorOption) => { const checkedColor = colorOption.closest('.variant-picker__option').querySelector('input[checked]'); // Add null check before accessing value if (checkedColor && variantBackgrounds && Object.values(variantBackgrounds).length > 0) { persDefault = variantBackgrounds[checkedColor.value]; } }); } const defaultQuantity = parseFloat("1") || 1; const quantityInput = document.querySelector('.f-quantity__input'); let defaultPrice = null; let currentVariantId = "50621700112684"; // Get tier pricing from product and variants const productPricingTiers = "0".split(',') .map(price => parseFloat(price)) .filter(price => !isNaN(price)); const productQuantityBreaks = "*".split(',') .map(qty => qty.trim() === '*' ? '*' : parseInt(qty)) .filter(qty => qty === '*' || !isNaN(qty)); // Store variant metafields const variantMetafields = JSON.parse('[ { "id": 50621700112684, "price": "6.99", "pricing_tiers": "0", "quantity_breaks": "*", "minimum_quantity": 1 } ]' || '[]'); // Current tier pricing data let currentPricingTiers = []; let currentQuantityBreaks = []; let useProductPricing = true; function updateDefaultPrice() { let salePriceElement = document.querySelector('.product-page-container .f-price.f-price--on-sale .f-price-item--sale'); let regularPriceElement = document.querySelector('.product-page-container .f-price .f-price-item--regular'); if (salePriceElement) { defaultPrice = parseFloat(salePriceElement.textContent.replace('$', '')) || null; } else if (regularPriceElement) { defaultPrice = parseFloat(regularPriceElement.textContent.replace('$', '')) || null; } else { console.error('No price element found! Default price not updated.'); } // Update tier pricing data for the current variant updateTierPricingData(); // Update total price with new data updateTotalPrice(); } function updateTierPricingData() { // Find current variant in metafields const currentVariant = variantMetafields.find(v => v.id.toString() === currentVariantId.toString()); // Special case: specific variant that should use product pricing const isSpecialVariant = currentVariantId === "50562527559980"; const hasProductPricing = productPricingTiers.length > 0 && productQuantityBreaks.length > 0; if (currentVariant && currentVariant.pricing_tiers && currentVariant.quantity_breaks && currentVariant.pricing_tiers.trim() !== '' && currentVariant.quantity_breaks.trim() !== '') { // Use variant-specific pricing currentPricingTiers = currentVariant.pricing_tiers.split(',') .map(price => parseFloat(price)) .filter(price => !isNaN(price)); currentQuantityBreaks = currentVariant.quantity_breaks.split(',') .map(qty => qty.trim() === '*' ? '*' : parseInt(qty)) .filter(qty => qty === '*' || !isNaN(qty)); useProductPricing = false; } // Special case for specific variant ID else if (isSpecialVariant && hasProductPricing) { // Use product-level pricing for this specific variant currentPricingTiers = productPricingTiers; currentQuantityBreaks = productQuantityBreaks; useProductPricing = true; } else if (!currentVariant) { // No variant selected, use product pricing currentPricingTiers = productPricingTiers; currentQuantityBreaks = productQuantityBreaks; useProductPricing = true; } else { // Variant selected but no pricing tiers - use default price currentPricingTiers = []; currentQuantityBreaks = []; useProductPricing = false; } } function calculateTierPrice(quantity) { // If no tier pricing data available, use default price if (currentPricingTiers.length === 0 || currentQuantityBreaks.length === 0) { return defaultPrice || 0; } // Start with first tier price let tierPrice = currentPricingTiers[0]; // Find applicable price based on quantity for (let i = 0; i < currentQuantityBreaks.length; i++) { const break_ = currentQuantityBreaks[i]; if (break_ === '*') { // If we hit the "*" tier, use its price for all higher quantities if (quantity > currentQuantityBreaks[i - 1]) { return currentPricingTiers[i]; } break; } if (quantity > break_) { if (i + 1 < currentPricingTiers.length) { tierPrice = currentPricingTiers[i + 1]; } } } return tierPrice; } function updateTotalPrice() { const quantity = parseInt(quantityInput.value) || 1; const currentPrice = calculateTierPrice(quantity) > 0 ? calculateTierPrice(quantity) : defaultPrice; if (isNaN(currentPrice) || currentPrice === null) { console.warn("currentPrice is invalid:", currentPrice); return; } // Update the "You Pay" price const totalPrice = (quantity * currentPrice).toFixed(2); document.getElementById('YouPayValue-template--24116626784556__main').textContent = `$${totalPrice}`; // Update regular price document.querySelector('.regular-price').textContent = `($${currentPrice.toFixed(2)} each)`; } // Listen for manual quantity changes if (quantityInput) { quantityInput.addEventListener('change', function() { updateTotalPrice(); }); } // Detect Variant Change document.addEventListener("change", function (event) { if (event.target.matches('.variant-selector')) { setTimeout(() => { // Update the current variant ID const variantInput = document.querySelector('input[name="id"]'); if (variantInput) { currentVariantId = variantInput.value; } updateDefaultPrice(); }, 200); } }); // Also listen for the variant:changed event from the tier-pricing component document.addEventListener('variant:changed', (event) => { currentVariantId = event.detail.variant.id.toString(); updateDefaultPrice(); }); const priceObserver = new MutationObserver(() => { updateDefaultPrice(); }); const priceContainer = document.querySelector('.product-page-container'); if (priceContainer) { priceObserver.observe(priceContainer, { childList: true, subtree: true, characterData: true }); } else { console.warn('Price container not found. Observer not started.'); } updateDefaultPrice(); }); const addVariantPrices = () => { if ( !true ) { document.querySelectorAll('.variant-picker__option-button--button').forEach(function(item) { let selector = item.parentNode.getAttribute('data-variant-id'); let prices = variantPrices[selector]; if (prices) { // Create and append regular price span only if price is not 0 if (prices.price && prices.price !== 0 && prices.price !== '0' && prices.price !== null) { const priceSpan = document.createElement('span'); priceSpan.className = 'variant-regular-price'; priceSpan.textContent = `$${(prices.price / 100).toFixed(2)}`; // Clear any existing regular price spans const existingRegularPrices = item.querySelectorAll('.variant-regular-price'); existingRegularPrices.forEach(span => span.remove()); // Append regular price span item.appendChild(priceSpan); } } }); } }