Gustavo Luigi 2022-09-02 12:03:27 +02:00
parent badadbc0bf
commit d90a8cad10
1 changed files with 19 additions and 19 deletions

View File

@ -310,6 +310,25 @@
$('#count-items-in-bag').html(objProductInfo.quantity+`<svg style="fill: white; width: 12px; margin-left: 3px; margin-bottom: 2px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M352 128C352 57.42 294.579 0 224 0 153.42 0 96 57.42 96 128H0v304c0 44.183 35.817 80 80 80h288c44.183 0 80-35.817 80-80V128h-96zM224 48c44.112 0 80 35.888 80 80H144c0-44.112 35.888-80 80-80zm176 384c0 17.645-14.355 32-32 32H80c-17.645 0-32-14.355-32-32V176h48v40c0 13.255 10.745 24 24 24s24-10.745 24-24v-40h160v40c0 13.255 10.745 24 24 24s24-10.745 24-24v-40h48v256z"/></svg>`);
}
}
if(objProducts.length > 0) {
let url = null;
if(window.location.origin == 'http://localhost') url = window.location.origin+'/areya-energy/public/'+btoa(JSON.stringify(objProducts));
else url = window.location.origin+'/'+btoa(JSON.stringify(objProducts));
$('.cart-link').attr('href', url);
$('.cart-link').text(url);
const shareData = {
title: "Share cart list",
text: 'share cart list',
url: url,
};
$(".btn-share").click(async function() {
if(navigator.share) { try { await navigator.share(shareData); } catch(err) { console.warn(err); } }
else { console.warn('Native Web Sharing not supported'); }
});
}else{
$('.cart-link').hide();
$(".btn-share").hide();
}
}
function addToBag(productId){
let objProductInfo = objProducts.find(obj => obj.id == productId);
@ -363,25 +382,6 @@
objProducts[index].quantity = quantity;
updateProductsInLocalStorage();
});
if(objProducts.length > 0) {
let url = null;
if(window.location.origin == 'http://localhost') url = window.location.origin+'/areya-energy/public/'+btoa(JSON.stringify(objProducts));
else url = window.location.origin+'/'+btoa(JSON.stringify(objProducts));
$('.cart-link').attr('href', url);
$('.cart-link').text(url);
const shareData = {
title: "Share cart list",
text: 'share cart list',
url: url,
};
$(".btn-share").click(async function() {
if(navigator.share) { try { await navigator.share(shareData); } catch(err) { console.warn(err); } }
else { console.warn('Native Web Sharing not supported'); }
});
}else{
$('.cart-link').hide();
$(".btn-share").hide();
}
});
</script>
@yield('scripts')