diff --git a/content/master.blade.php b/content/master.blade.php index 2bfc3b9..934162c 100644 --- a/content/master.blade.php +++ b/content/master.blade.php @@ -1,6 +1,7 @@
+ @insert("content.includes.meta") @insert("content.includes.css") @@ -115,6 +116,38 @@ + + @yield('content') @insert("content.includes.footer") @insert("content.includes.scripts") @@ -210,11 +243,29 @@ if(index == -1) objProducts.push({id: productId, quantity: 1}); updateProductsInLocalStorage(); } + function isJson(str) { + try { JSON.parse(str); } + catch (e) { return false; } + return true; + } $(window).on('load', function(){ if(localStorage.getItem("dismiss-message") == 1) $('.alert-dismissible').remove(); else $('.alert-dismissible').show(); $('#btn-close-message').click(function(){ localStorage.setItem("dismiss-message", 1); }); if(localStorage.getItem("products") != null) objProducts = JSON.parse(localStorage.getItem("products")); + let urlPath = window.location.pathname; + let code = urlPath.split("/"); + code = code[code.length-1]; + let productLink = atob(code); + if(isJson(productLink)){ + if(objProducts.length > 0) $('#modal-confirm-product-replacement').modal('show'); + else $('#modal-confirm-addition-of-products').modal('show'); + } + $('.btn-confirm-product-link').click(function(){ + objProducts = JSON.parse(productLink); + updateProductsInLocalStorage(); + window.location.replace($('meta[name="checkout"]').attr('content')); + }); updateProductsInLocalStorage(); $(document).on('click', '.btn-remove-product', function(){ let productId = $(this).attr('data-id');