Helmets for Field Use


Helmets for Field Use – Green Gridiron, Inc. {0}”. Please try again with a different term.”,”productSearchResultWithTermSummary”:”{0} results for ‘{1}'”,”productSearchResultSummary”:”{0} products”,”productSearchNoResults”:”

No matching for ‘{0}’.

But don’t give up – check the filters, spelling or try less specific search terms.”,”productSearchNoResultsEmptyTerm”:”

No results found.

But don’t give up – check the filters or try less specific terms.”,”clearAll”:”Clear all”,”clear”:”Clear”,”clearAllFilters”:”Clear all filters”,”clearFiltersBy”:”Clear filters by {0}”,”filterBy”:”Filter by {0}”,”sort”:”Sort”,”sortBy_r”:”Relevance”,”sortBy_title”:”Title: A-Z”,”sortBy_-title”:”Title: Z-A”,”sortBy_date”:”Date: Old to New”,”sortBy_-date”:”Date: New to Old”,”sortBy_price”:”Price: Low to High”,”sortBy_-price”:”Price: High to Low”,”sortBy_-discount”:”Discount: High to Low”,”sortBy_bestselling”:”Best selling”,”sortBy_-available”:”Inventory: High to Low”,”sortBy_producttype”:”Product Type: A-Z”,”sortBy_-producttype”:”Product Type: Z-A”,”filters”:”Filters”,”filterOptions”:”Filter options”,”clearFilterOptions”:”Clear all filter options”,”youHaveViewed”:”You’ve viewed {0} of {1} products”,”loadMore”:”Load more”,”loadPrev”:”Load previous”,”productMatches”:”Product matches”,”trending”:”Trending”,”didYouMean”:”Sorry, nothing found for ‘{0}’.
Did you mean ‘
{1}’?”,”searchSuggestions”:”Search suggestions”,”quantity”:”Quantity”,”selectedVariantNotAvailable”:”The selected variant is not available.”,”addToCart”:”Add to cart”,”seeFullDetails”:”See full details”,”chooseOptions”:”Choose options”,”quickView”:”Quick view”,”sale”:”Sale”,”save”:”Save”,”soldOut”:”Sold out”,”viewItems”:”View items”,”more”:”More”,”all”:”All”,”prevPage”:”Previous page”,”gotoPage”:”Go to page {0}”,”nextPage”:”Next page”,”from”:”From”,”collections”:”Collections”,”pages”:”Pages”,”sortBy_”:”Relevance”,”sortBy_option:Amount”:”Amount: A-Z”,”sortBy_-option:Amount”:”Amount: Z-A”,”sortBy_option:Award Decal”:”Award Decal: A-Z”,”sortBy_-option:Award Decal”:”Award Decal: Z-A”,”sortBy_option:Clip Color”:”Clip Color: A-Z”,”sortBy_-option:Clip Color”:”Clip Color: Z-A”,”sortBy_option:Color”:”Color: A-Z”,”sortBy_-option:Color”:”Color: Z-A”,”sortBy_option:Color & Size”:”Color & Size: A-Z”,”sortBy_-option:Color & Size”:”Color & Size: Z-A”,”sortBy_option:Country”:”Country: A-Z”,”sortBy_-option:Country”:”Country: Z-A”,”sortBy_option:Decal”:”Decal: A-Z”,”sortBy_-option:Decal”:”Decal: Z-A”,”sortBy_option:Helmet Type”:”Helmet Type: A-Z”,”sortBy_-option:Helmet Type”:”Helmet Type: Z-A”,”sortBy_option:Placement”:”Placement: A-Z”,”sortBy_-option:Placement”:”Placement: Z-A”,”sortBy_option:Quantity”:”Quantity: A-Z”,”sortBy_-option:Quantity”:”Quantity: Z-A”,”sortBy_option:Shell Color”:”Shell Color: A-Z”,”sortBy_-option:Shell Color”:”Shell Color: Z-A”,”sortBy_option:Shell Size”:”Shell Size: A-Z”,”sortBy_-option:Shell Size”:”Shell Size: Z-A”,”sortBy_option:Size”:”Size: A-Z”,”sortBy_-option:Size”:”Size: Z-A”,”sortBy_option:SportStar Adapter Color”:”SportStar Adapter Color: A-Z”,”sortBy_-option:SportStar Adapter Color”:”SportStar Adapter Color: Z-A”,”sortBy_option:State”:”State: A-Z”,”sortBy_-option:State”:”State: Z-A”,”sortBy_option:Style”:”Style: A-Z”,”sortBy_-option:Style”:”Style: Z-A”,”sortBy_option:Title”:”Title: A-Z”,”sortBy_-option:Title”:”Title: Z-A”,”sortBy_option:Visor Style”:”Visor Style: A-Z”,”sortBy_-option:Visor Style”:”Visor Style: Z-A”,”sortBy_option:Type”:”Type: A-Z”,”sortBy_-option:Type”:”Type: Z-A”}} } ]]>

{const e=o[r]%16;return r++,(“x”===t?e:3&e|8).toString(16)})).toUpperCase()}catch(n){e=t.replace(/[x]/g,(t=>{const e=16*Math.random()|0;return(“x”===t?e:3&e|8).toString(16)})).toUpperCase()}return`${function(){let t=0,e=0;t=(new Date).getTime()>>>0;try{e=performance.now()>>>0}catch(t){e=0}const n=Math.abs(t+e).toString(16).toLowerCase();return”00000000″.substr(0,8-n.length)+n}()}-${e}`}()}`}function r(n,r){if(!t[n]||”trekkie”!==(null==r?void 0:r.analyticsFramework)&&”wpm”!==(null==r?void 0:r.analyticsFramework))return o(“shu”);const i=”string”==typeof(c=r.cacheKey)&&c?c:”default”;var c;const a=function(t,n,o){const r=e[n];return void 0===r[t]&&(r[t]={}),void 0===r[t][o]?r[t][o]=0:r[t][o]+=1,r[t][o]}(n,r.analyticsFramework,i);return function(e,n,r){const i=t[e];if(void 0===i[r]){const t=o();i[r]=[t]}else if(void 0===i[r][n]){const t=o();i[r].push(t)}return i[r][n]}(n,a,i)}function i(){window.Shopify=window.Shopify||{},n(),window.Shopify.evids=(t,e)=>r(t,e)}i();})(); ]]> { console.error(“Elevar Data Layer: JS script failed to load”); }; script.onload = () => { if (!window.ElevarGtmSuite) { console.error(“Elevar Data Layer: `ElevarGtmSuite` is not defined”); return; } const cartData = { attributes:{}, cartTotal: “0.0”, currencyCode:”USD”, items: [] } ; if (config.event_config.save_order_notes) { window.ElevarGtmSuite.handlers.cookieReconcile(cartData); window.ElevarGtmSuite.handlers.paramReconcile(cartData); } if (config.event_config.user) { window.ElevarGtmSuite.handlers.user({cartTotal: “0.0”, currencyCode:”USD”,}); } if (config.event_config.product_add_to_cart_ajax) { window.ElevarGtmSuite.handlers.productAddToCartAjax(config.event_config.save_order_notes); } if (config.event_config.cart_reconcile) { window.ElevarGtmSuite.handlers.cartReconcile(cartData); }const collectionItems ={ currencyCode:”USD”, items: [{id:”RID-00117″,name:”Riddell SpeedFlex Black Out – ADULT”, brand:”Riddell”, category:”Helmet/Field Use/Adult”, price: “509.99”, position:1, productId: “118266331149”, variantId: “42639112929449”, handle:”riddell-speedflex-football-helmet”},{id:”RID-00235″,name:”Riddell SpeedFlex – YOUTH”, brand:”Riddell”, category:”Helmet/Field Use/Youth”, price: “409.99”, position:2, productId: “511604228161”, variantId: “6840360304705”, handle:”riddell-speedflex-youth-football-helmet”},{id:”SCH-00126″,name:”Schutt F7 VTD Black Out – ADULT”, brand:”Schutt”, category:”Helmet/Field Use/Adult”, price: “427.99”, position:3, productId: “1569320239169”, variantId: “38573828702377”, handle:”schutt-f7-vtd-football-helmet”},{id:”VIC-00063″,name:”Vicis Zero2 Helmet – ADULT”, brand:”Vicis”, category:”Helmet/Field Use/Adult”, price: “799.99”, position:4, productId: “6564816257193”, variantId: “40809102966953”, handle:”vicis-zero-2-helmet”},{id:”SCH-00172″,name:”Schutt F7 VTD LX1 – YOUTH”, brand:”Schutt”, category:”Helmet/Field Use/Youth”, price: “259.99”, position:5, productId: “3949975011393”, variantId: “31124858404929”, handle:”schutt-f7-vtd-football-helmet-youth”},{id:”SCH-00218″,name:”Schutt Vengeance A11 – YOUTH”, brand:”Schutt”, category:”Helmet/Field Use/Youth”, price: “180.99”, position:6, productId: “4326678167617”, variantId: “31125065891905”, handle:”schutt-a11-football-helmet-youth”},{id:”RID-01264″,name:”Riddell Speed Victor-I – YOUTH”, brand:”Riddell”, category:”Helmet/Field Use/Youth”, price: “119.99”, position:7, productId: “7626836017321”, variantId: “42662037029033”, handle:”riddell-speed-victor-i-youth”},{id:”SYZ-00001″,name:”Syzmik X7 Soft Shell Football Headgear”, brand:”Syzmik”, category:”Helmet/Field Use/Soft”, price: “97.0”, position:8, productId: “7733444018345”, variantId: “43021985579177”, handle:”syzmik-x7-soft-shell-football-helmet”},{id:”RID-01411″,name:”Riddell SpeedFlex Youth Helmet, Metallic Silver, Small – Scratch u0026 Dent”, brand:”Riddell”, category:”Helmet/Field Use/Youth”, price: “369.99”, position:9, productId: “7743908151465”, variantId: “43058224267433”, handle:”riddell-speedflex-youth-helmet-metallic-silver-small-scratch-dent”},{id:”RID-01412″,name:”Riddell SpeedFlex Adult Helmet, Black, Small – Scratch u0026 Dent”, brand:”Riddell”, category:”Helmet/Field Use/Youth”, price: “449.99”, position:10, productId: “7743909527721”, variantId: “43058226823337”, handle:”riddell-speedflex-adult-helmet-black-small-scratch-dent”},{id:”RID-01415″,name:”Riddell SpeedFlex Youth Helmet, Navy, X-Large- Scratch u0026 Dent”, brand:”Riddell”, category:”Helmet/Field Use/Youth”, price: “544.99”, position:11, productId: “7746340126889”, variantId: “43066572701865”, handle:”riddell-speedflex-youth-helmet-navy-x-large-scratch-dent-1″},{id:”RID-01416″,name:”Riddell SpeedFlex Youth Helmet, Matte Black, Large – Scratch u0026 Dent”, brand:”Riddell”, category:”Helmet/Field Use/Youth”, price: “499.99”, position:12, productId: “7748583850153”, variantId: “43073911619753”, handle:”riddell-speedflex-youth-helmet-matte-black-large-scratch-dent-2″},] }; if (config.event_config.collection_view) { window.ElevarGtmSuite.handlers.collectionView(collectionItems); } if (config.event_config.product_select) { window.ElevarGtmSuite.handlers.productSelect(collectionItems); }}; document.body.appendChild(script); })(); ]]> 1) Shopify.updateOptionsInSelector(1); if (product.options.length === 3) Shopify.updateOptionsInSelector(2); // When there is an update in the first dropdown. jQuery(“.single-option-selector:eq(0)”).change(function() { console.log(‘FIRST OPTION’); Shopify.updateOptionsInSelector(1); if (product.options.length === 3) Shopify.updateOptionsInSelector(2); return true; }); // When there is an update in the second dropdown. jQuery(“.single-option-selector:eq(1)”).change(function() { console.log(‘SECOND OPTION :: ‘ + $(this).val()); if($(‘body’).attr(‘id’) === ‘riddell-speed-victor-i-youth’) { checkFacemaskSize($(this).val()); } if (product.options.length === 3) Shopify.updateOptionsInSelector(2); return true; }); }; var selector = jQuery(‘.single-option-selector:eq(0)’); selector.trigger(‘change’); }); ]]> “) ]]> ‘, ‘”‘: ‘”‘, “‘”: ‘'’, ‘/’: ‘/’, ‘`’: ‘`’, ‘=’: ‘=’ } Object.keys(entityMap).map(function(k) { s = s.replace(k, entityMap[k]) }) return s } function sasoTrimLength(str, maxLen) { var separator = ” ” if (str.length {{{product_message}}}

{{#tiers}}
Minimum Qty {{# if price_type_flat}}Price per item{{/if}}{{# if price_type_percent}}Discount{{/if}}
{{{quantity}}}+ {{{price.title}}} {{/tiers}} ]]>

Apply ]]> expiration) { // expired localStorage.removeItem(‘nvdconfig’); nvd_config = null; prefetch(); } // var tomorrow = new Date(); // tomorrow.setDate(today.getDate()+3); useConsole(‘Navidium config avaialable in storage’); } else { useConsole(‘Navidium config not available in storage’); await fetch( `https://app.navidiumapp.com/api/widet-serverless-api-stable-september-2022.php?shop_url=${nvdShop}` ) .then((res) => res.json()) .then((initialData) => { useConsole(initialData); showWidget = initialData.nvd_show_cart; autoInsurance = initialData.nvd_auto_insurance; let today = new Date() // extract the configuration data let shopConfig = { success: initialData.success, show_on_cart: initialData.nvd_show_cart, show_on_checkout: initialData.nvd_show_checkout, auto_insurance: initialData.nvd_auto_insurance, nvd_name: initialData.nvd_name, product_exclusion: initialData.product_exclusion.split(‘,’), nvd_subtitle: initialData.nvd_subtitle, nvd_description: initialData.nvd_description, nvd_message: initialData.nvd_message, protection_variants: initialData.nvd_variants, min_protection_price: initialData.min_protection_value, max_protection_price: initialData.max_protection_value, protection_type: initialData.nvd_protection_type, protection_percentage: initialData.nvd_protection_type_value, min_protection_variant: initialData.min_variant_id, max_protection_variant: initialData.max_variant_id, expiration: today.setDate(today.getDate() + 3), widget_location: initialData.widget_location, widget_icon : initialData.nvd_widget_icon, }; // store into localStorage localStorage.setItem(‘nvdconfig’, JSON.stringify(shopConfig)); if (callback) return callback(); }).catch(err => { useConsole(‘%c navidium error’, ‘color: yellow; background-color: red; font-size: 12px’, err); }); } }; const calculateProtection = async (cartTotal, nvdConfig) => { let conversionRate = parseFloat(Shopify.currency.rate); let convertedTotal = cartTotal/ conversionRate; let protectionType = nvdConfig.protection_type; let protectionPercentage = nvdConfig.protection_percentage; let protectionId; let protectionPrice; let minPrice = Number(nvdConfig.min_protection_price); let maxPrice = Number(nvdConfig.max_protection_price); let minId = nvdConfig.min_protection_variant; let maxId = nvdConfig.max_protection_variant; let protectionVariants = nvdConfig.protection_variants; // TODO: check protection type if (protectionType == ‘1’) { // protection is dynamic let ourProtectionPrice = (convertedTotal * protectionPercentage) / 100; ourProtectionPrice = ourProtectionPrice.toFixed(2); // calculate the protection if (ourProtectionPrice maxPrice) { console.log(‘Our protection price is greater than maximum’); protectionPrice = maxPrice; protectionId = maxId; return { price: protectionPrice, variant_id: protectionId } } else { console.log(‘calculating protection’) function findClosest(arr, target) { let finalOutput = 0.00; let n = arr.length; target = parseFloat(target); let current; for (let i = 0; i = parseFloat(arr[i]) && target <= parseFloat(arr[i + 1])) { finalOutput = arr[i + 1]; break; } else if (target a - b); protectionPrice = findClosest(priceArray, ourProtectionPrice); if (protectionPrice == 0) { return { price: maxPrice, variant_id: maxId } } protectionId = protectionVariants[protectionPrice]; return { price: protectionPrice, variant_id: protectionId } } } else { // protection is static.so hit the api console.log('protection is static'); let apiURL = await fetch(`https://app.navidiumapp.com/api/variant-id-checker-api-march6.php?shop_url=${shop}&price=` + cartTotal); let data = apiURL.json(); return data; } } const nvd_init = async () => { let shopCurrency = ‘${{amount}} USD’; console.time(‘nvd_init’); localStorage.setItem(‘nvd_running’, true); // TODO: check nvd_config in localStorage let shopConfig = localStorage.getItem(‘nvdconfig’) ? JSON.parse(localStorage.getItem(‘nvdconfig’)) : null; // check if shop config data is available in localStorage if (shopConfig) { useConsole(‘Navidium config avaialable in storage’); } else { // if not available, fetch from server and store in localStorage useConsole(‘Navidium config not avaialable in storage. Prefetching now’); await prefetch(nvd_init); return; } let cartProtectionVariant = localStorage.getItem(‘cart_protection’) ? localStorage.getItem(‘cart_protection’) : null; let opted_out = JSON.parse(localStorage.getItem(‘nvd_opted_out’)); let showWidget = true; if (shopConfig.show_on_cart == “0”) { showWidget = false; } useConsole(‘showWidget’, showWidget); let success = true; if (shopConfig.success == “0”) { success = false; } let checked; let nvd_variant; useConsole(‘in cart protection variant’, cartProtectionVariant); // check if widget should be shown and limit did not exceeded if (showWidget == true && success == true) { let cart = await getCartCallback(checkCart); let cartTotal = await cart.total / 100; let currency = await cart.currency; useConsole(‘after exclusion total price is’, cartTotal); let getProtection = await calculateProtection(cartTotal, shopConfig); let variantFromApi = await getProtection.variant_id; let priceFromApi = await getProtection.price; useConsole(‘apiJson’, getProtection); if (cartTotal == 0) { useConsole(‘cart total is zero.No need to add protection’); return; } else { // check for opt in status first if (shopConfig.auto_insurance == ‘1’) { useConsole(‘auto insurance is true’); checked = true; } if (shopConfig.auto_insurance == ‘0’) { checked = false; } if (opted_out == true) { useConsole(‘user has not opted in’); checked = false; } if (opted_out == false) { useConsole(‘ use has opted in’); checked = true; } useConsole(‘widget check status: ‘, checked); // now check the variant in cart is equal to the variant in api return if (cartProtectionVariant) { if (cartProtectionVariant == variantFromApi) { useConsole( ‘1. cart variant is same as the api variant,stay idle and build widget’, cartProtectionVariant, variantFromApi ); nvd_variant = cartProtectionVariant; if (document.querySelector(‘.nvd-mini’)) document.querySelectorAll(‘.nvd-mini’).forEach((item) => { item.innerHTML = buildWidget( shopConfig, priceFromApi, nvd_variant, checked ? ‘checked’ : ” ); }); checkWidgetView(); } else { useConsole( ‘cart variant and api variant is not same.swapping them now’ ); nvd_variant = variantFromApi; // now remove the previous navidium variant from cart if (cartProtectionVariant) { // now add the new protection to the cart if (checked) { useConsole(‘removing old and adding new protection’); await removeAndAddProtection( cartProtectionVariant, variantFromApi, false ); } } // now append the snippet if (document.querySelector(‘.nvd-mini’)) document.querySelectorAll(‘.nvd-mini’).forEach((item) => { item.innerHTML = buildWidget( shopConfig, priceFromApi, nvd_variant, checked ? ‘checked’ : ” ); }); checkWidgetView(); } } else { if (checked) { useConsole( ‘Protection Not available. Adding now.’, cartProtectionVariant, variantFromApi ); nvd_variant = variantFromApi; await addProtection(Number(variantFromApi), 1, true); if (document.querySelector(‘.nvd-mini’)) document.querySelectorAll(‘.nvd-mini’).forEach((item) => { item.innerHTML = buildWidget( shopConfig, priceFromApi, nvd_variant, checked ? ‘checked’ : ” ); }); checkWidgetView(); } else { nvd_variant = variantFromApi; useConsole(‘no protection available, just append snippet’); if (document.querySelector(‘.nvd-mini’)) document.querySelectorAll(‘.nvd-mini’).forEach((item) => { item.innerHTML = buildWidget( shopConfig, priceFromApi, nvd_variant, checked ? ‘checked’ : ” ); }); checkWidgetView(); } } } } else { // when navidium widget is shut off useConsole( ‘%c Navidium Message:widget is shut off or limit reached.Please turn on from your app settings or check you have not exceeded your limit’, ‘color: yellow; background-color: blue; font-size: 12px’ ); } console.timeEnd(‘nvd_init’); localStorage.setItem(‘nvd_running’, false); updateWidgetPrice(); }; // function to get cart data and pass the data to another callback for processing. const getCartCallback = async (callback) => { let cart = await fetch(‘/cart.js’); let cartData = await cart.json(); if (callback) return callback(cartData); return cartData; }; // function to check cart items const checkCart = async (cartData, callback = null) => { let currency = await cartData.currency; useConsole(‘cart in check cart’, cartData); if (cartData.items.length != 0) { let items = cartData.items; let total = parseFloat(cartData.total_price); let initialTotal = cartData.total_price; let nvd_counter_array = []; let recheck = false; let dupeVariant; let counter = items.length; let shopConfig = localStorage.getItem(‘nvdconfig’) ? JSON.parse(localStorage.getItem(‘nvdconfig’)) : null; let excludedSKUs = shopConfig.product_exclusion; // if no shop config is found wait and call prefetch if (!shopConfig) { await prefetch(); } useConsole(‘product exclusion’, excludedSKUs); let promises = await items.forEach((item) => { // check for duplicate navidium if (item.handle.includes(‘navidium-shipping-protection’)) { nvd_counter_array.push(item.variant_id); useConsole(‘protection available in cart’); localStorage.setItem(‘cart_protection’, item.variant_id); total = total – item.final_line_price; useConsole(‘nvd1’, total); if (item.quantity > 1) { useConsole(‘Found duplicate protection in cart,decreasing now’); recheck = true; dupeVariant = item.variant_id; } else { useConsole(‘protection duplication test passed’); } } else { counter = counter + item.quantity; excludedSKUs.forEach((sku) => { if (item.sku == sku) { useConsole( ‘%c Navidium Message:Product is excluded’, ‘color: yellow; background-color: blue; font-size: 16px’, item.sku, item.final_price ); // substract the item price from total total = total – item.final_line_price; useConsole(‘ex1’, total); } }); } }); if (recheck == true) { let mutateCart = adjustProtectionQuantity(dupeVariant, 0, false); useConsole(‘calling checkCart function recursively’, mutateCart); getCartCallback(checkCart); } if (nvd_counter_array.length > 1) { useConsole( ‘%cfound more than one variant of navidium protection in cart,removing all now’, ‘color:red’ ); await nvd_counter_array.forEach((item) => { useConsole(‘removing variant’, item); adjustProtectionQuantity(item, 0); localStorage.removeItem(‘cart_protection’); recheck = false; }); } if (nvd_counter_array.length == 0) { useConsole(‘No protection available in cart’); localStorage.removeItem(‘cart_protection’); } if (nvd_counter_array.length == items.length) { useConsole(‘no items in cart rather than protection’); fetch(‘/cart/clear.js’).then((res) => { useConsole(‘cart cleared’); location.reload(); localStorage.removeItem(‘cart_protection’); }); } // if recheck is true and duplicate protection is available call checkCart the function recursively return { total: parseFloat(total), currency: currency, }; } else { return { total: 0, currency: currency, }; } }; // function to add protection to cart const addProtection = async (variantId, quantity = 1, reload = false) => { const id = parseInt(variantId); if (document.querySelectorAll(‘[name=”checkout”]’)) document.querySelectorAll(‘[name=”checkout”]’).forEach(elem => elem.disabled = true) let cartData; var request = { method: ‘POST’, headers: { ‘Content-Type’: ‘application/json;’, Accept: ‘application/json’, }, body: JSON.stringify({ id: id, quantity: quantity, }), }; cartData = await fetch(‘/cart/add.js’, request); let cartJson = await cartData.json(); if (cartJson.id) { useConsole( ‘%c Protection added successfully’, ‘color: white; background-color: green’ ); updateLiveCart(null); if (document.querySelectorAll(‘[name=”checkout”]’)) document.querySelectorAll(‘[name=”checkout”]’).forEach(elem => elem.disabled = false) } else { if (document.querySelectorAll(‘[name=”checkout”]’)) document.querySelectorAll(‘[name=”checkout”]’).forEach(elem => elem.disabled = false) } console.dir(cartJson); localStorage.setItem(‘nvd_opted_out’, false); localStorage.setItem(‘cart_protection’, variantId); checkWidgetView(); if (reload == true) { location.reload(); } else { return cartJson; } }; // function to remove protection const removeProtection = async (variantId, reload = false) => { if (document.querySelectorAll(‘[name=”checkout”]’)) document.querySelectorAll(‘[name=”checkout”]’).forEach(elem => elem.disabled = true) var request = { method: ‘POST’, headers: { ‘Content-Type’: ‘application/json;’, Accept: ‘application/json’, }, body: JSON.stringify({ id: String(variantId), quantity: 0, }), }; cartData = await fetch(‘/cart/change.js’, request); let cartJson = await cartData.json(); localStorage.setItem(‘nvd_opted_out’, true); localStorage.removeItem(‘cart_protection’); if (cartJson.token) { if (document.querySelectorAll(‘[name=”checkout”]’)) document.querySelectorAll(‘[name=”checkout”]’).forEach(elem => elem.disabled = false) useConsole( ‘%c Protection removed successfully’, ‘color: white; background-color: red’ ); updateLiveCart(cartJson); } else { if (document.querySelectorAll(‘[name=”checkout”]’)) document.querySelectorAll(‘[name=”checkout”]’).forEach(elem => elem.disabled = false) } checkWidgetView(); if (reload == true) { location.reload(); } else { return cartJson; } }; // function to update protection variant from cart const adjustProtectionQuantity = async ( variantId, quantity, reload = false ) => { let cartData; var request = { method: ‘POST’, headers: { ‘Content-Type’: ‘application/json;’, Accept: ‘application/json’, }, body: JSON.stringify({ id: String(variantId), quantity: String(quantity), }), }; cartData = await fetch(‘/cart/change.js’, request); let cartJson = await cartData.json(); useConsole( ‘%cnew cart instance after duplicate protection quantity decrease’, ‘color:yellow’, cartJson ); console.dir(cartJson); updateLiveCart(cartJson); if (reload == true) { location.reload(); } else { return cartJson; } }; let updateWidgetPrice = async () => { useConsole(‘updating widget price’); let cartData = await fetch(‘/cart.js’).then(res => res.json()); let widget = document.querySelector(‘#nvd-widget-cart’); if (widget == null) return; let shopCurrency = ‘${{amount}} USD’; let items = await cartData.items; items.forEach((item) => { useConsole(item); if (item.handle.includes(‘navidium-shipping-protection’)) { useConsole(‘ updating navidium price’) let price = Shopify.formatMoney(item.price, shopCurrency); let priceElem = document.querySelector(‘.shipping-protection-price’); if (priceElem) priceElem.innerHTML = price; } }); }; // function remove and add protection to cart const removeAndAddProtection = async (remove, add, reload = false) => { if (document.querySelectorAll(‘[name=”checkout”]’)) document.querySelectorAll(‘[name=”checkout”]’).forEach(elem => elem.disabled = true) const removeRequest = { method: ‘POST’, headers: { ‘Content-Type’: ‘application/json;’, Accept: ‘application/json’, }, body: JSON.stringify({ id: String(remove), quantity: 0, }), }; const addRequest = { method: ‘POST’, headers: { ‘Content-Type’: ‘application/json;’, Accept: ‘application/json’, }, body: JSON.stringify({ id: String(add), quantity: 1, }), }; await fetch(‘/cart/change.js’, removeRequest) .then((res) => res.json()) .then((data) => { useConsole(‘removed and now adding’); fetch(‘/cart/add.js’, addRequest) .then((res) => res.json()) .then((data) => { if (data.id) { useConsole( ‘%c Protection swapped successfully’, ‘color: white; background-color: green’ ); updateLiveCart(null); if (document.querySelectorAll(‘[name=”checkout”]’)) document.querySelectorAll(‘[name=”checkout”]’).forEach(elem => elem.disabled = false) } localStorage.setItem(‘nvd_opted_out’, false); localStorage.setItem(‘cart_protection’, add); if (reload) { location.reload(); } }).catch(err => { if (document.querySelectorAll(‘[name=”checkout”]’)) document.querySelectorAll(‘[name=”checkout”]’).forEach(elem => elem.disabled = false) }); }); }; // widget switch on/off listener function const getShippingProtection = async (variantId, price, element) => { if (!element.checked) { useConsole(‘unchecking and removing protection’); await removeProtection(variantId, true); } else { useConsole(‘checked and adding protection’); await addProtection(parseInt(variantId), 1, true); } }; // function to update subtotal and dom cart item’s line id const updateLiveCart = async (cartData = null) => { let cart = cartData; if (cart == null) cart = await getCartCallback(); let shopCurrency = ‘${{amount}} USD’; let totalPrice = Shopify.formatMoney(cart.total_price, shopCurrency); let cartItems = cart.items; let totalCount = cart.item_count; let opted_out = Boolean(JSON.parse(localStorage.getItem(‘nvd_opted_out’))); // change the cart item class name here. let lineAttribute = ‘data-line’; let quantityPlus = ‘qty_plus’; let quantityMinus = ‘qty_minus’; let removeItem = ‘.remove’; let totalElem = document.querySelectorAll(‘.nvd-subtotal’); let cartCountElem = document.querySelectorAll(‘.cart-count’); let cartItemNodes = document.querySelectorAll(‘.cart-row’); let cartItemsList = Array.from(cartItemNodes); // if not opted out show one less in count if (!opted_out) current_count = totalCount – 1; if (opted_out) current_count = totalCount; if (cart.item_count == 0) current_count = 0; useConsole(‘current and cart count’, current_count, totalCount); if (totalElem) totalElem.forEach((elem) => (elem.innerHTML = totalPrice)); if (cartCountElem) cartCountElem.forEach((elem) => (elem.innerHTML = current_count)); await updateCartLine( lineAttribute, cartItemsList, cartItems, quantityPlus, quantityMinus, removeItem ); }; // function to update the line index in dom cart line items let updateCartLine = async ( lineAttribute, cartItemsList, cartItems, qtyPlus, qtyMinus, rmvItem ) => { useConsole(cartItemsList, lineAttribute); // for every line item in cart dom check with the cart items. await cartItemsList.forEach((item) => { if (item.innerHTML.toString().includes(‘/products/navidium-shipping-protection’) == true) { item.style.display = ‘none’ } cartItems.forEach((cartItem, index) => { if (item.innerHTML.toString().includes(cartItem.url)) { useConsole(item.querySelector(`[${lineAttribute}]`)); let lineItem = item.querySelectorAll(`[${lineAttribute}]`); let removeItem = item.querySelectorAll(rmvItem); let quantityPlus = item.querySelectorAll(qtyPlus); let quantityMinus = item.querySelectorAll(qtyMinus); if (lineItem) item.setAttribute(lineAttribute, index + 1) lineItem.forEach((item) => item.setAttribute(lineAttribute, index + 1) ); if (quantityPlus) quantityPlus.forEach((item) => item.setAttribute( ‘data-href’, `/cart/change?quantity=${cartItem.quantity + 1}&line=${index + 1 }` ) ); if (quantityMinus) quantityMinus.forEach((item) => item.setAttribute( ‘data-href’, `/cart/change?quantity=${cartItem.quantity – 1}&line=${index + 1 }` ) ); if (removeItem) removeItem.forEach((item) => item.setAttribute( ‘href’, `/cart/change?line=${index + 1}&quantity=0` ) ); useConsole(‘line id updated’); } }); }); }; // opt in message toggle function const checkWidgetView = () => { let optedOut = localStorage.getItem(‘nvd_opted_out’); let selected = document.querySelectorAll(‘.nvd-selected’); let deselected = document.querySelectorAll(‘.nvd-dis-selected’); if (optedOut == ‘true’) { selected.forEach(elem => { elem.style.display = ‘none’ }) deselected.forEach(elem => { elem.style.display = ‘block’ }) } else { selected.forEach(elem => { elem.style.display = ‘block’ }) deselected.forEach(elem => { elem.style.display = ‘none’ }) } }; // function that will track the widget real time const trackWidget = () => { let nvd_running = localStorage.getItem(‘nvd_running’); let startTracking = setInterval(() => { let nvdContainer = document.querySelector(‘.nvd-mini’); let hasWidget; if (nvdContainer) hasWidget = nvdContainer.innerHTML.length; if (hasWidget { let shopCurrency = ‘${{amount}} USD’; let nvd_name = shopConfig.nvd_name; let nvd_subtitle = shopConfig.nvd_subtitle; let nvd_description = shopConfig.nvd_description; let nvd_message = shopConfig.nvd_message; let protection_price = priceFromApi; let protected_variant = nvd_variant; let widgetIcon = shopConfig.widget_icon; let protection_checkbox = checked ? ‘checked’ : ” let selectedStyle = protection_checkbox ? “‘display: block'” : “‘display: none'”; let diselectedStyle = protection_checkbox ? “‘display: none'” : “‘display: block'”; var snippet = ` Navidium icon

${nvd_name}

Helmets for Field Use

If you have any question please CONTACT  Us
Email us at:  info@discountsportsinc.com
Call US : (832) 722-8074

Don’t Forget to Visit our Shop 

For reliable and quality Managed IT Services and VoIP, Contact Precise Business Solutions 

Leave a Reply

Your email address will not be published. Required fields are marked *