add cart list
parent
65543e6617
commit
57844a9804
|
@ -1,6 +1,7 @@
|
|||
<!doctype html>
|
||||
<html lang="{{str_replace('_', '-', app()->getLocale())}}">
|
||||
<head>
|
||||
<meta name="checkout" content="{{url('/checkout')}}">
|
||||
<meta name="get-contents" content="{{url('/contents/all')}}">
|
||||
@insert("content.includes.meta")
|
||||
@insert("content.includes.css")
|
||||
|
@ -115,6 +116,38 @@
|
|||
<button type="button" class="btn-close" id="btn-close-message" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade bd-example-modal-sm" id="modal-confirm-addition-of-products" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Você gostaria de colocar os produtos do link no carrinho?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary btn-confirm-product-link" data-bs-dismiss="modal">Ja</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Nein</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade bd-example-modal-sm" id="modal-confirm-product-replacement" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Você possui produtos no carrinho, deseja descartar e colocar os produtos do link no carrinho?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary btn-confirm-product-link" data-bs-dismiss="modal">Ja</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Nein</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@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');
|
||||
|
|
Loading…
Reference in New Issue