Glow15: Glow Kitchen Recipes (2024)

'; mini_cart_item_html += '

'; mini_cart_item_html += '

'; if (data.image) { mini_cart_item_html += '' + '' + ''; } else if ( data.featured_image ) { mini_cart_item_html += '' + '' + ''; } else { var image = "//naomiw.com/cdn/shop/t/403/assets/no-image_100x100.jpg?85410"; mini_cart_item_html += '' + '' + ''; } mini_cart_item_html += '

'; mini_cart_item_html += '

'; mini_cart_item_html += '

'; mini_cart_item_html += '

'; mini_cart_item_html += '

'; mini_cart_item_html += ''; mini_cart_item_html += ''; mini_cart_item_html += '' + item_title + ''; // Display frequency name if( frequencyName ) { mini_cart_item_html += ''+frequencyName+''; } if(discounts.length > 0 ) { mini_cart_item_html += ''+ data.discounts[0].title +''; } mini_cart_item_html += ''; mini_cart_item_html += ''; mini_cart_item_html += ''; if( compare_at_price ) { mini_cart_item_html += '' + Shopify.formatMoney(compare_at_price) + ''; } if( rebuyGift === true ) { mini_cart_item_html += '' + Shopify.formatMoney(data.discounted_price) + ''; } else if( discounts.length > 0 ) { mini_cart_item_html += '' + Shopify.formatMoney(data.price) + ''; mini_cart_item_html += '' + Shopify.formatMoney(data.discounted_price) + ''; } else { mini_cart_item_html += '' + Shopify.formatMoney(data.price) + ''; } mini_cart_item_html += ''; mini_cart_item_html += ''; mini_cart_item_html += ''; mini_cart_item_html += '

'; if ( ! add_to_cart ) { mini_cart_item_html += '

'; mini_cart_item_html += '

'; if( rebuyGift === false ) { mini_cart_item_html += '

'; mini_cart_item_html += ''; mini_cart_item_html += ''; mini_cart_item_html += ''; mini_cart_item_html += '

'; mini_cart_item_html += '

'; mini_cart_item_html += '

'; mini_cart_item_html += ''; mini_cart_item_html += '

'; if( data.properties ) { mini_cart_item_html += '

'; mini_cart_item_html += '

'; if( data.properties.shipping_interval_frequency != null && data.properties.shipping_interval_unit_type != null ) { mini_cart_item_html += 'Deliver every '+ data.properties.shipping_interval_frequency +' '+ data.properties.shipping_interval_unit_type +''; } mini_cart_item_html += '

'; mini_cart_item_html += '

'; } } else { // mini_cart_item_html += ''+ data.discounts[0].title +'' } mini_cart_item_html += '

'; } else { mini_cart_item_html += '

'; } mini_cart_item_html += '

'; if (has_sub == true && subProductObject.selling_plan != null && minicart_subscription_upsell == true) { mini_cart_item_html += 'Upgrade to subscribe and save'; } mini_cart_item_html += ''; return mini_cart_item_html; } function beforeSend_mini_cart(addToCartForm, open_cart) { var cart_message = wpr.find('[data-js="cart_message"]'); var mini_cart_items = wpr.find('[data-js="mini_cart_items"]'); var order_bump_items = wpr.find('[data-js="order_bump_items"]'); var free_gift_wpr = wpr.find('[data-js="free_gift_wpr"]'); var rebuy_widget = wpr.find('.rebuy-widget'); var cart_subtotal = wpr.find('[data-js="cart_subtotal"]'); cart_message.empty(); mini_cart_items.empty(); order_bump_items.hide().empty(); if(typeof free_gift_wpr !== 'undefined' ) { free_gift_wpr.hide(); } rebuy_widget.hide(); cart_subtotal.empty(); if ( addToCartForm != null ) { var addToCartBtn = addToCartForm.find('.ProductForm__AddToCart, input[type="submit"]'); addToCartBtn.attr('disabled', 'disabled').addClass('disabled'); if ( addToCartBtn.is('input') ) { addToCartBtn.val('Adding...'); } else { if( addToCartBtn.hasClass('return-text') ) { let addtoCartBtnText = addToCartBtn.html(); addToCartBtn.html(''); addToCartBtn.append('Adding...'); } else { addToCartBtn.text('Adding...'); } } } mini_cart_items.append(loading_html); if (open_cart) { wpr.addClass('active'); } } function on_return( addToCartForm, error) { if ( addToCartForm != null ) { var addToCartBtn = addToCartForm.find('.ProductForm__AddToCart, input[type="submit"]'); var subscribeText = $(addToCartBtn).attr('data-original'); if ( addToCartBtn.is('input') ) { if (error == undefined) { addToCartBtn.val('Added'); } else { addToCartBtn.val('error'); } window.setTimeout(function(){ addToCartBtn.removeAttr('disabled').removeClass('disabled'); if(subscribeText == 'Subscribe Now'){ addToCartBtn.val(subscribeText); } else { addToCartBtn.val('Add to Cart'); } }, 1000); } else { if (error == undefined) { if( addToCartBtn.hasClass('return-text') ) { let addToCartBtnOldText = addToCartBtn.find('.old-text').contents().clone(); addToCartBtn.text('Added'); setTimeout( function() { addToCartBtn.html(addToCartBtnOldText); }, 3000); console.log(addToCartBtnOldText); } else { addToCartBtn.text('Added'); } } else { addToCartBtn.text('error'); } window.setTimeout(function(){ addToCartBtn.removeAttr('disabled').removeClass('disabled'); if (addToCartBtn.hasClass('btn-plus')) { addToCartBtn.html('Add to cart +'); } else { if(subscribeText == 'Subscribe Now'){ addToCartBtn.val(subscribeText); } else { addToCartBtn.val('Add to Cart'); } } }, 1000); } } } async function get_tags(handle) { $.ajax({ async: false, url:'/products/' + handle + '.js', type:'GET', success:function(response){ var response = JSON.parse(response), tags = response.tags; if( tags.includes("acquisition") ) { return true; } } }); } async function getAllTags(handle) { let itemTags = []; await fetch('/products/'+handle+'.js', {cache: 'no-cache'}) .then(response => response.json()) .then(item => { itemTags = item.tags; }); return itemTags; } async function refreshCart(cart) { $(document).trigger( "refreshCart" ); var cart_message = wpr.find('[data-js="cart_message"]'); var mini_cart_items = wpr.find('[data-js="mini_cart_items"]'); var order_bump_items = wpr.find('[data-js="order_bump_items"]'); var rebuy_widget_regular_products = wpr.find('#rebuy-widget-6594'); var rebuy_widget_SS_products = wpr.find('#rebuy-widget-7261'); var cart_subtotal = wpr.find('[data-js="cart_subtotal"]'); var cross_sale = wpr.find('#cross_sale'); var cart_message_html = ""; var cart_items_html = ""; var cart_action_html = ""; if ( cart.item_count == 0 ) { cart_message_html += "

Your cart is empty

"; } else { const tags = []; let free_shipping = false; $.each(cart.items, function(index, item) { fetchMetafieldsJSON(item).then(metafields => { metafields = JSON.stringify(metafields) .replace(/<[^>]*>?/gm, '') // Remove HTML tags .replace(/(\r\n|\n|\r)/gm, '') // Remove newlines .replace(/\\/g, '') // Remove backslashes .replace('{"cart_accentuate":"', '') // Remove prefix .replace(/""/g, '","') // Replace double quotes .replace(/},]/g, '}]') // Correct closing brackets .slice(0, -2); // Remove last two characters metafields = JSON.parse(metafields); cart_products = metafields; var has_sub = false; var subProductObject = {}; $.each(cart_products, function(i, cartitem) { if (cartitem.handle == item.handle) { if (cartitem.sub_product == ',') { has_sub = false; sub_prod = ''; } else { has_sub = true; sub_prod = cartitem.sub_product; if (minicart_subscription_upsell == true) { // Make an API request to fetch the product data $.ajax({ url: '/products/' + sub_prod + '.js', method: 'GET', async: false, data: { handle: sub_prod, }, success: function (response) { var data_response = JSON.parse(response); if (response && response.length > 0) { var subProductId = data_response.id; var subVariantId = data_response.variants[0].id; var selling_plan_ID = data_response.selling_plan_groups[0].selling_plans[0].id; subProductObject = { product_id: subProductId, id: subVariantId, selling_plan: selling_plan_ID }; } else { console.log("Sub product not found."); } }, error: function () { console.log("Failed to fetch sub product data."); }, }); } } } }); cart_items_html += mini_cart_item(item, false, has_sub, sub_prod, subProductObject); mini_cart_items.html(cart_items_html); }).catch(error => { console.error('Error:', error); return; }); }); // get items tags and merge them together for (let i = 0; i < cart.items.length; i++) { const item = cart.items[i]; itemTags = await getAllTags(item.handle); tags.push(...itemTags); } // remove once testing is complete! console.log('item tags',tags); // check if certain tags exist if(tags.includes('free-shipping')) { free_shipping = true; } console.log('1', free_shipping); cross_sale.hide(); //if( thsCrossSale.options.enableCrossSell != true ) { rebuy_widget_SS_products.hide(); rebuy_widget_regular_products.hide(); var show_ss_rebuy_widget = true; var acquisition = false; $.each(cart.items, function(index, item) { if ( item.product_title.indexOf("90-Day Supply") == -1 && item.product_title.indexOf("9-Month Supply") == -1 ) { show_ss_rebuy_widget = false; //return false; } }); var acquisitionResults = []; var itemCount = cart.items.length; function get_tags(handle, callback) { $.ajax({ async: false, url: '/products/' + handle + '.js', type: 'GET', success: function (response) { var responseObj = JSON.parse(response); var tags = responseObj.tags; //var free_shipping = false; if (tags.includes("acquisition")) { callback(true); //if (tags.includes("free-shipping")) { // var free_shipping = true; //} } else { callback(false); } }, error: function (err) { console.error('Error:', err); callback(false); } }); } function processItem(index) { if (index < itemCount) { get_tags(cart.items[index].handle, function (result) { acquisitionResults.push(result); processItem(index + 1); return acquisitionResults; }); } } processItem(0); if( acquisitionResults.includes(true) ) { acquisition = true; } // if ( show_ss_rebuy_widget ) { // // rebuy_widget_SS_products.show(); // } else { // rebuy_widget_regular_products.show(); // } rebuy_widget_regular_products.show(); //} thsCrossSale.init(cart); var diff = 7500 - cart.total_price; var per = map(cart.total_price, 0, 7500, 0, 100); var free_gift_wpr = document.getElementById('free_gift_wpr'); if (free_shipping == true) { order_bump_items.html('

  • '+ 'STOCKUP: FREE SHIPPING'+ '
    '+ '
  • '); order_bump_items.show(); } else if ( (cart.total_price < 7500 && ! show_ss_rebuy_widget && acquisition === false) ) { if ( order_bump_items.find('.message').length == 0 ) { order_bump_items.html('

  • '+ 'You're '+ Shopify.formatMoney(diff) +' away from free shipping!'+ '
    '+ '
  • '); order_bump_items.show(); } } else { //if ( order_bump_items.find('.message').length == 0 ) { order_bump_items.html('

  • '+ 'CONGRATULATIONS! YOU\'VE GOT FREE SHIPPING'+ '
    '+ '
  • '); order_bump_items.show(); //} } if ( (cart.total_price < 7500 && ! show_ss_rebuy_widget && acquisition === false && free_shipping === false) ) { cart_action_html += '

  • '+ 'SUBTOTAL' + '' + Shopify.formatMoney(cart.total_price) + '
    +$5.95 US Shipping
    '+ '
  • '; } else { cart_action_html += '

  • '+ 'SUBTOTAL' + '' + Shopify.formatMoney(cart.total_price) + ''+ '
  • '; } cart_action_html += '

  • ' + '

    ' + //'

    ' + //'Cart' + //'

    ' + //'

    ' + '' + //'

    ' + '

    ' + '
  • '; if( free_gift_wpr !== null) { free_gift_wpr.style.display = "block"; } } cart_message.html(cart_message_html); mini_cart_items.html(cart_items_html); cart_subtotal.html(cart_action_html); $('.Header__CartCount').html(cart.item_count); if ( cart.item_count > 0) { $('.Header__CartCount').removeClass('hidden'); } else { $('.Header__CartCount').addClass('hidden'); } } $(document).on('click', '.ProductForm__AddToCart', function(e) { e.preventDefault(); var addToCartForm = $(this).closest('form'); // Added as a fix to scroll issue when cart is active $("body").css("height", "100%"); $("body").css("overflow", "hidden"); $('#cross_sale').hide(); $.ajax({ url: '/cart/add.js', dataType: 'json', cache: false, type: 'post', data: addToCartForm.serialize(), beforeSend: function() { beforeSend_mini_cart(addToCartForm, true); }, success: function(itemData) { on_return(addToCartForm); $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { refreshCart(cart); } }); }, error: function(XMLHttpRequest) { console.log( XMLHttpRequest.responseText ); on_return(addToCartForm, 'error'); $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { refreshCart(cart); } }); } }); return false; }); $(document).on('click', '.cart-popup-wrapper .QuantitySelector__Button', function(e) { e.preventDefault(); var url = $(this).data("url"), text = $(this).text(); $(this).text('Removing...'); $('#cross_sale').hide(); $('#free_gift_wpr').hide(); $.ajax({ url: url, cache: false, beforeSend: function() { beforeSend_mini_cart(null, true); }, success: function(itemData) { updateCart().then(() => { on_return(); $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { refreshCart(cart); } }); }); }, error: function(XMLHttpRequest) { console.log( XMLHttpRequest.responseText ); on_return(); $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { refreshCart(cart); } }); } }); // "update" the cart to force async function updateCart() { try { const response = await fetch(window.Shopify.routes.root + 'cart/update.js', { method: 'POST', }); if (!response.ok) { throw new Error('Network response was not ok'); } const data = await response.json(); } catch (error) { console.error('Error during cart update:', error); } } return false; }); $(document).on("keypress", '.cart-popup-wrapper .QuantitySelector__CurrentQuantity', function(e) { if (event.keyCode == 13) { var quantity = $(this).val(); var line_id = $(this).data("line-id"); var url = '/cart/change?quantity='+quantity+'&id='+ line_id; $('#cross_sale').hide(); $.ajax({ url: url, cache: false, beforeSend: function() { beforeSend_mini_cart(null, true); }, success: function(itemData) { on_return(); $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { refreshCart(cart); } }); }, error: function(XMLHttpRequest) { console.log( XMLHttpRequest.responseText ); $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { refreshCart(cart); } }); } }); } }); $(document).on('click', '.cart-popup-wrapper .Checkout-Button', function(e) { e.preventDefault(); var paramCart = '&cart_token=' + (document.cookie.match('(^|; )cart=([^;]*)')||0)[2]; $.ajax({ type: 'GET', url: '/cart.js', dataType: 'text', success: function(data) { var url = '/checkout'; window.location.href = url; $('.cart-popup-wrapper .Checkout-button').attr("href", url); } }); return false; }); $(document).ready(function () { if( thsCrossSale.options.enableCrossSell != true ) { document.addEventListener('rebuy.ready', function(event){ $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { beforeSend_mini_cart(null, false); refreshCart(cart); } }); }); document.addEventListener('rebuy.add', function(event){ $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { beforeSend_mini_cart(null, true); refreshCart(cart); } }); }); } document.addEventListener('rebuy.add', function(event) { const widgetID = event.detail.widget.id; if( widgetID != '131054' ) { return; } let messageWpr = document.getElementById('free_gift_wpr'); if( messageWpr ) { messageWpr.classList.add('hidden'); } $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { console.log("ajax refreshCart", cart); refreshCart(cart); } }); }); document.addEventListener('rebuy.remove', function(event) { const widgetID = event.detail.widget.id; if( widgetID != '131054' ) { return; } let messageWpr = document.getElementById('free_gift_wpr'); if( messageWpr ) { messageWpr.classList.remove('hidden'); } $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { console.log("ajax refreshCart", cart); refreshCart(cart); } }); }); document.addEventListener('rebuy.ready', function(event){ const widgetID = event.detail.widget.id if( widgetID != '131054' ) { return; } let matchedRules = event.detail.widget.data.metadata.matched_rules, messageWpr = document.getElementById('free_gift_wpr'); if( messageWpr ) { if(matchedRules.length > 0 ) { messageWpr.classList.add('hidden'); } else { messageWpr.classList.remove('hidden'); } } }); $('#cross_sale').hide(); $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { beforeSend_mini_cart(null, false); refreshCart(cart); } }); }) // This is required to allow thsCrossSale the ability to use the refreshCart function function crossSaleRefreshCart() { $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function(cart) { refreshCart(cart); } }); } window.crossSaleRefreshCart = crossSaleRefreshCart; if (minicart_subscription_upsell == true) { // Add an event listener to handle the click event on the "Upgrade" button $(document).on('click', '.upgrade', function(e) { e.preventDefault(); var subscribeHandle = $(this).data('subscribe-handle'); console.log('Subscription product handle:', subscribeHandle); // Find the current product's line item in the cart var currentProductID = $(this).data('current-product-id'); var subProductId = $(this).data('sub-product-id'); var subVariantId = $(this).data('sub-product-var-id'); var selling_plan_ID = $(this).data('sub-product-selling-plan'); if (subProductId && currentProductID) { $.ajax({ url: '/cart/change?quantity=0&id=' + currentProductID, dataType: 'json', success: function(response) { addToCart(subscribeHandle, subProductId, subVariantId, selling_plan_ID); }, error: function(error) { console.error('Error removing the current product from the cart:', error); } }); } }); function getVariantIdFromHandle(subscribeHandle, callback) { $.ajax({ url: '/products/' + subscribeHandle + '.js', dataType: 'json', cache: false, type: 'get', success: function(productData) { // Check if productData contains variants if (productData.variants && productData.variants.length > 0) { var variantId = productData.variants[0].id; callback(variantId); } else { console.error('No variants found for the product.'); callback(null); } }, error: function(XMLHttpRequest) { console.error('Error fetching product data:', XMLHttpRequest); callback(null); } }); } // Function to add a product to the cart function addToCart(subscribeHandle, subProductId, subVariantId, selling_plan_ID) { $('#cross_sale').hide(); $.ajax({ url: '/cart/add.js', dataType: 'json', cache: false, async: false, type: 'post', data: { items: [{ product_id: subProductId, id: subVariantId, quantity: 1, selling_plan: selling_plan_ID }] }, beforeSend: function () { beforeSend_mini_cart(null, true); // No form to pass here }, success: function (itemData) { on_return(null); $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function (cart) { refreshCart(cart); } }); }, error: function (XMLHttpRequest) { console.error('Error response from /cart/add.js:', XMLHttpRequest); on_return(null, 'error'); $.ajax({ url: '/cart.js', dataType: "json", cache: false, success: function (cart) { refreshCart(cart); } }); } }); } } })();

    Glow15: Glow Kitchen Recipes (2024)
    Top Articles
    Latest Posts
    Article information

    Author: The Hon. Margery Christiansen

    Last Updated:

    Views: 5495

    Rating: 5 / 5 (70 voted)

    Reviews: 85% of readers found this page helpful

    Author information

    Name: The Hon. Margery Christiansen

    Birthday: 2000-07-07

    Address: 5050 Breitenberg Knoll, New Robert, MI 45409

    Phone: +2556892639372

    Job: Investor Mining Engineer

    Hobby: Sketching, Cosplaying, Glassblowing, Genealogy, Crocheting, Archery, Skateboarding

    Introduction: My name is The Hon. Margery Christiansen, I am a bright, adorable, precious, inexpensive, gorgeous, comfortable, happy person who loves writing and wants to share my knowledge and understanding with you.