(function () { if (document.getElementById("reforestation-app-load") !== null) { return; } document.querySelector("body").insertAdjacentHTML('beforeend', ''); var hash = 'QewVajrVqJ'; var sessionId = '0c8b56c0d8b6cee5fd4a9888c18b0233'; var variantId = '48547586343257'; var checkout = window.Shopify && window.Shopify.checkout; var oneTreePlanted = function (jQuery) { jQuery('body').prepend(''); jQuery('[data-selector="one-tree-planted-tree-counter"]').html('0'); var hasProductInCart = false; if (typeof checkout !== "undefined") { checkout['line_items'].forEach(lineItem => { if(lineItem.variant_id == variantId || lineItem.title === 'Tree to be Planted' || lineItem.vendor === 'One Tree Planted' || lineItem.title === 'Donation of a Tree' || lineItem.vendor === 'Donation of a Tree') { hasProductInCart = true; } }); if(hasProductInCart === false){ if(jQuery('[data-variant-id="' + variantId + '"]').length > 0) { hasProductInCart = true; } } } else if(typeof window.Shopify.Checkout == "undefined") { jQuery.ajax({ url: "/cart.json?onetree=1", type: "GET", success: function (result) { if (result.items != undefined) { for (var i = 0; i < result.items.length; i++) { if (result.items[i].variant_id == variantId) { hasProductInCart = true; break; } } } var cartPage = { init: function () { if(jQuery('.one-tree-checkbox-container').length > 0){ return; } this.prepareContent(); this.eventListener(); }, prepareContent: function () { var content; var css; if(!hasProductInCart){ css = '\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003Cstyle\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020flex\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020justify\u002Dcontent\u003A\u0020flex\u002Dend\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020color\u003A\u0020\u0023000000\u0020\u0021important\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020font\u002Dsize\u003A\u002015px\u0020\u0021important\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020margin\u002Dtop\u003A\u002010px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0040media\u0020all\u0020and\u0020\u0028max\u002Dwidth\u003A\u0020540px\u0029\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020justify\u002Dcontent\u003A\u0020center\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020input\u005Btype\u003Dcheckbox\u005D\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020visibility\u003A\u0020hidden\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u00200\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u00200\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020input\u005Btype\u003Dcheckbox\u005D\u003Achecked\u0020\u002B\u0020label\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020rotate\u0028360deg\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020background\u002Dcolor\u003A\u0020\u002393c24f\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020input\u005Btype\u003Dcheckbox\u005D\u003Achecked\u0020\u002B\u0020label\u003Abefore\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020translateX\u002822px\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020background\u002Dcolor\u003A\u0020\u0023ffffff\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020label\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020flex\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002046px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002023px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u003A\u00201px\u0020solid\u0020\u002393c24f\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dradius\u003A\u002099em\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020relative\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020cursor\u003A\u0020pointer\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020label\u003Abefore\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020content\u003A\u0020\u0022\u0022\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020absolute\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002017px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002017px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020background\u002Dcolor\u003A\u0020\u0023000000\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dradius\u003A\u002050\u0025\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020top\u003A\u00202px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020left\u003A\u00203px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020.one\u002Dtree\u002Dswitch\u002Dcontainer\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020flex\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020margin\u002Dleft\u003A\u00205px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dlearn\u002Dmore\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020flex\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020align\u002Ditems\u003A\u0020center\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dlearn\u002Dmore\u002Dcontent\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u0020200px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020text\u002Dalign\u003A\u0020left\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020font\u002Dweight\u003A\u0020normal\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020font\u002Dsize\u003A\u002013px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dchevron\u002Ddown\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020box\u002Dsizing\u003A\u0020border\u002Dbox\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020relative\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020scale\u0028var\u0028\u002D\u002Dggs,1\u0029\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002022px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002022px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u003A\u00202px\u0020solid\u0020transparent\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dradius\u003A\u0020100px\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dchevron\u002Ddown\u003A\u003Aafter\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020content\u003A\u0020\u0022\u0022\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020box\u002Dsizing\u003A\u0020border\u002Dbox\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020absolute\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002010px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002010px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dbottom\u003A\u00202px\u0020solid\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dright\u003A\u00202px\u0020solid\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020rotate\u002845deg\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020left\u003A\u00204px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020top\u003A\u00202px\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dchevron\u002Dup\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020box\u002Dsizing\u003A\u0020border\u002Dbox\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020relative\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020scale\u0028var\u0028\u002D\u002Dggs,1\u0029\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002022px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002022px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u003A\u00202px\u0020solid\u0020transparent\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dradius\u003A\u0020100px\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dchevron\u002Dup\u003A\u003Aafter\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020content\u003A\u0020\u0022\u0022\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020box\u002Dsizing\u003A\u0020border\u002Dbox\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020absolute\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002010px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002010px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dtop\u003A\u00202px\u0020solid\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dright\u003A\u00202px\u0020solid\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020rotate\u0028\u002D45deg\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020left\u003A\u00204px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020bottom\u003A\u00202px\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u003C\/style\u003E\n'; content = '\u0020\u0020\u0020\u0020\u003Cdiv\u0020class\u003D\u0022one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0022\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003Cspan\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020Wil\u0020je\u0020een\u0020boom\u0020planten\u0020via\u0020One\u0020Tree\u0020Planted\u0020voor\u0020\u20AC\u00200.93\u0020per\u0020stuk\u003F\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003C\/span\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003Cspan\u0020class\u003D\u0022one\u002Dtree\u002Dswitch\u002Dcontainer\u0022\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003Cinput\u0020type\u003D\u0022checkbox\u0022\u0020name\u003D\u0022checkbox\u0022\u0020id\u003D\u0022one\u002Dtree\u002Dtoggle\u0022\u0020data\u002Dselector\u003D\u0022one\u002Dtree\u002Dswitch\u0022\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003Clabel\u0020for\u003D\u0022one\u002Dtree\u002Dtoggle\u0022\u003E\u003C\/label\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003C\/span\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003C\/div\u003E\n'; }else{ css = '\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003Cstyle\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020flex\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020justify\u002Dcontent\u003A\u0020flex\u002Dend\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020color\u003A\u0020\u0023000000\u0020\u0021important\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020font\u002Dsize\u003A\u002015px\u0020\u0021important\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020margin\u002Dtop\u003A\u002010px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0040media\u0020all\u0020and\u0020\u0028max\u002Dwidth\u003A\u0020540px\u0029\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020justify\u002Dcontent\u003A\u0020center\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020input\u005Btype\u003Dcheckbox\u005D\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020visibility\u003A\u0020hidden\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u00200\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u00200\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020input\u005Btype\u003Dcheckbox\u005D\u003Achecked\u0020\u002B\u0020label\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020rotate\u0028360deg\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020background\u002Dcolor\u003A\u0020\u002393c24f\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020input\u005Btype\u003Dcheckbox\u005D\u003Achecked\u0020\u002B\u0020label\u003Abefore\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020translateX\u002822px\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020background\u002Dcolor\u003A\u0020\u0023ffffff\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020label\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020flex\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002046px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002023px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u003A\u00201px\u0020solid\u0020\u002393c24f\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dradius\u003A\u002099em\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020relative\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020cursor\u003A\u0020pointer\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020label\u003Abefore\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020content\u003A\u0020\u0022\u0022\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020absolute\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002017px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002017px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020background\u002Dcolor\u003A\u0020\u0023000000\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dradius\u003A\u002050\u0025\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020top\u003A\u00202px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020left\u003A\u00203px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0020.one\u002Dtree\u002Dswitch\u002Dcontainer\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020flex\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020margin\u002Dleft\u003A\u00205px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dlearn\u002Dmore\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020flex\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020align\u002Ditems\u003A\u0020center\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dlearn\u002Dmore\u002Dcontent\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u0020200px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020text\u002Dalign\u003A\u0020left\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020font\u002Dweight\u003A\u0020normal\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020font\u002Dsize\u003A\u002013px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dchevron\u002Ddown\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020box\u002Dsizing\u003A\u0020border\u002Dbox\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020relative\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020scale\u0028var\u0028\u002D\u002Dggs,1\u0029\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002022px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002022px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u003A\u00202px\u0020solid\u0020transparent\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dradius\u003A\u0020100px\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dchevron\u002Ddown\u003A\u003Aafter\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020content\u003A\u0020\u0022\u0022\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020box\u002Dsizing\u003A\u0020border\u002Dbox\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020absolute\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002010px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002010px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dbottom\u003A\u00202px\u0020solid\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dright\u003A\u00202px\u0020solid\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020rotate\u002845deg\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020left\u003A\u00204px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020top\u003A\u00202px\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dchevron\u002Dup\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020box\u002Dsizing\u003A\u0020border\u002Dbox\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020relative\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020scale\u0028var\u0028\u002D\u002Dggs,1\u0029\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002022px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002022px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u003A\u00202px\u0020solid\u0020transparent\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dradius\u003A\u0020100px\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020.one\u002Dtree\u002Dchevron\u002Dup\u003A\u003Aafter\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020content\u003A\u0020\u0022\u0022\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020box\u002Dsizing\u003A\u0020border\u002Dbox\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020absolute\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u002010px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020height\u003A\u002010px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dtop\u003A\u00202px\u0020solid\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020border\u002Dright\u003A\u00202px\u0020solid\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020transform\u003A\u0020rotate\u0028\u002D45deg\u0029\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020left\u003A\u00204px\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020bottom\u003A\u00202px\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007D\n\u0020\u0020\u0020\u0020\u003C\/style\u003E\n'; content = '\u0020\u0020\u0020\u0020\u003Cdiv\u0020class\u003D\u0022one\u002Dtree\u002Dcheckbox\u002Dcontainer\u0022\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003Cspan\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020Wil\u0020je\u0020een\u0020boom\u0020planten\u0020via\u0020One\u0020Tree\u0020Planted\u0020voor\u0020\u20AC\u00200.93\u0020per\u0020stuk\u003F\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003C\/span\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003Cspan\u0020class\u003D\u0022one\u002Dtree\u002Dswitch\u002Dcontainer\u0022\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003Cinput\u0020type\u003D\u0022checkbox\u0022\u0020name\u003D\u0022checkbox\u0022\u0020id\u003D\u0022one\u002Dtree\u002Dtoggle\u0022\u0020data\u002Dselector\u003D\u0022one\u002Dtree\u002Dswitch\u0022\u0020checked\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003Clabel\u0020for\u003D\u0022one\u002Dtree\u002Dtoggle\u0022\u003E\u003C\/label\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003C\/span\u003E\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u003C\/div\u003E\n'; } global.appendContent(css); if(jQuery('.one-tree-planted-wrapper').length > 0){ jQuery('.one-tree-planted-wrapper').append(content); }else{ jQuery('form[action*="/cart"]').append(content); } console.log('One tree cart page initialize'); }, changeSwitch: function (element) { if(hasProductInCart){ if(element.attr('id') === "one-tree-toggle"){ jQuery('[data-selector="one-tree-switch"]').removeAttr('checked'); } global.deleteProductInCart(); (function waitForIt() { setTimeout(function () { global.checkHasProductInCart(function (result) { if(!result){ window.location = window.location.pathname; }else{ waitForIt(); } }); }, 1000); })(); }else{ if(element.attr('id') === "one-tree-toggle"){ jQuery('[data-selector="one-tree-switch"]').attr('checked', ''); } if(variantId.length === 0){ return; } global.addProductToCart(); (function waitForIt() { setTimeout(function () { global.checkHasProductInCart(function (result) { if(result){ window.location = window.location.pathname; }else{ waitForIt(); } }); }, 1000); })(); } }, toggleLearnMore: function () { jQuery('.one-tree-learn-more-content').toggle(); if(jQuery('.one-tree-learn-more i').hasClass('one-tree-chevron-up')){ jQuery('.one-tree-learn-more i').removeClass('one-tree-chevron-up'); jQuery('.one-tree-learn-more i').addClass('one-tree-chevron-down'); }else{ jQuery('.one-tree-learn-more i').removeClass('one-tree-chevron-down'); jQuery('.one-tree-learn-more i').addClass('one-tree-chevron-up'); } }, eventListener: function () { var self = this; jQuery(document).on('click', '[data-selector="one-tree-switch"], [data-selector="one-tree-checkbox"]', function () { self.changeSwitch(jQuery(this)); }); jQuery(document).on('click', '.one-tree-learn-more', function (){ self.toggleLearnMore(); }); } }; if (window.location.pathname.indexOf('/cart') !== -1 || jQuery('.one-tree-planted-wrapper').length > 0) { cartPage.init(); } } }); } }; var global = { jq: null, init: function () { this.eventListener(); }, loadScript: function (url, callback) { var script = document.createElement("script"); script.type = "text/javascript"; if (script.readyState) { script.onreadystatechange = function () { if (script.readyState === "loaded" || script.readyState === "complete") { script.onreadystatechange = null; callback(); } }; } else { script.onload = function () { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }, appendContent: function (content) { this.jq(document.body).prepend(content); }, checkHasProductInCart: function (callback) { var self = this; self.jq.ajax({ url: "/cart.json?onetree=1", type: "GET", success: function (result) { var items = result.items; var hasProductInCart = false; if (items !== undefined) { for (var i = 0; i < items.length; i++) { if (parseInt(items[i].variant_id) === parseInt(variantId)) { hasProductInCart = true; break; } } } setTimeout(function () { callback(hasProductInCart) }, 0); } }); }, addProductToCart: function (callback) { let quantity = 1; const http = new XMLHttpRequest(); http.open('POST', '/cart/add.js', true); http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); http.onreadystatechange = function () { if (http.readyState === 4) { if (typeof callback === "function") { callback(); } } }; http.send("id=" + variantId + "&quantity=" + quantity); }, addProductToCartFromThankYouPage: function () { const http = new XMLHttpRequest(); http.open('POST', 'https://cloud.reforestationapp.com/thank-you-page-add-to-cart', true); http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); http.onreadystatechange = function () { if (http.readyState === 4) { if (http.status === 200) { const response = JSON.parse(http.responseText); if (response.success === true) { window.location.href = response.redirectUrl; } else { if (response.message.length > 0) { alert(response.message); } } } } }; http.send("shop=806bad-23.myshopify.com&date=" + new Date() + "&sessionId=" + sessionId + "&hash=" + hash + "&checkoutToken=" + checkout["token"] + "&orderId=" + checkout["order_id"]); }, deleteProductInCart: function () { this.jq.post('/cart/change.js', { quantity: 0, id: variantId, async: true }); }, eventListener: function () { var self = this; if ((typeof jQuery === 'undefined') || (typeof jQuery.ajax === 'undefined') || (parseFloat(jQuery.fn.jquery) < 1.7)) { self.loadScript('//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', function () { var jQuery311 = jQuery.noConflict(true); self.jq = jQuery311; oneTreePlanted(jQuery311); }); } else { self.jq = jQuery; oneTreePlanted(jQuery); } } }; global.init(); })();