Double click the content to see meaning
NOW AT STARBUCKS!
Try Now
Shop
Purpose
Try Now
Shop
Purpose
404 Page Not Found
The page you are looking for does not exist.
Go to Home
Your Cart
Your cart is empty
Product
Total
{ if (isChanging || $store.cart.isLoading) return; isChanging = true; const isChecked = e.target.checked; const itemKey = item.key; const variantId = item.id; const quantity = item.quantity; console.log('Item data:', item); console.log('Available properties:', Object.keys(item)); try { if (isChecked) { // Try multiple ways to get product handle let handle = null; // Log all attempts console.log('Trying to extract handle...'); console.log('item.handle:', item.handle); console.log('item.url:', item.url); console.log('item.product_title:', item.product_title); console.log('item.title:', item.title); // Try different properties if (item.handle) { handle = item.handle; } else if (item.url) { const match = item.url.match(/\/products\/([^?\/]+)/); handle = match ? match[1] : null; } else if (item.product_handle) { handle = item.product_handle; } else if (item.product_title || item.title) { // Create handle from title const title = item.product_title || item.title || ''; handle = title.toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/^-+|-+$/g, ''); } console.log('Extracted handle:', handle); if (!handle) { throw new Error('Could not determine product handle'); } const productResponse = await fetch(`/products/${handle}.js`); if (!productResponse.ok) { throw new Error('Product not found'); } const productData = await productResponse.json(); console.log('Product data:', productData); // Find the variant const variant = productData.variants.find(v => v.id === parseInt(variantId)); console.log('Found variant:', variant); if (!variant || !variant.selling_plan_allocations || variant.selling_plan_allocations.length === 0) { throw new Error('No subscription plans available for this product'); } // Log available plans console.log('Available selling plans:', variant.selling_plan_allocations); // Check the structure of the first selling plan if (variant.selling_plan_allocations[0]) { console.log('First selling plan structure:', variant.selling_plan_allocations[0]); console.log('Selling plan keys:', Object.keys(variant.selling_plan_allocations[0])); } // Get the selling plan ID - check different possible structures let sellingPlanId; const firstAllocation = variant.selling_plan_allocations[0]; if (firstAllocation.selling_plan && firstAllocation.selling_plan.id) { sellingPlanId = firstAllocation.selling_plan.id; } else if (firstAllocation.selling_plan_id) { sellingPlanId = firstAllocation.selling_plan_id; } else if (firstAllocation.id) { sellingPlanId = firstAllocation.id; } else { throw new Error('Could not find selling plan ID in the expected format'); } console.log('Using selling plan ID:', sellingPlanId); // Remove current item await fetch('/cart/change.js', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: itemKey, quantity: 0 }) }); // Add with subscription const addResponse = await fetch('/cart/add.js', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: variantId, quantity: quantity, selling_plan: sellingPlanId }) }); const addResult = await addResponse.json(); if (!addResponse.ok) { throw new Error(addResult.description || 'Failed to add item'); } } else { // Remove subscription - just remove and re-add without selling plan await fetch('/cart/change.js', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: itemKey, quantity: 0 }) }); // Add without subscription const addResponse = await fetch('/cart/add.js', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: variantId, quantity: quantity }) }); const addResult = await addResponse.json(); if (!addResponse.ok) { throw new Error(addResult.description || 'Failed to add item'); } } // Fetch updated cart const cartResponse = await fetch('/cart.js'); const cartData = await cartResponse.json(); // Update the store with new cart data Alpine.store('cart').items = cartData.items; Alpine.store('cart').totalPrice = (cartData.total_price / 100).toFixed(2); Alpine.store('cart').itemsCount = cartData.item_count; } catch (error) { console.error('Error toggling subscription:', error); console.error('Full error details:', error.stack); // Revert checkbox on error e.target.checked = !isChecked; alert('Error: ' + error.message); } finally { isChanging = false; } }" :disabled="isChanging || $store.cart.isLoading" >
Subscribe & Save
-
+
You may also like
Madagascar Vanilla, Honey + Almond
12 Nut & Seed Bars
$30.00
Add +
Chocolate Chip
5 Whole Grain Bars
$8.00
Add +
Peruvian Dark Chocolate + Peanut Butter
12 Nut & Seed Bars
$30.00
Add +
S'mores
5 Whole Grain Bars
$8.00
Add +
Total items:
Total price:
$
Proceed to Checkout