You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.4 KiB
57 lines
1.4 KiB
function getCookie(cname) {
|
|
var name = cname + "=";
|
|
var ca = document.cookie.split(';');
|
|
for(var i = 0; i < ca.length; i++) {
|
|
var c = ca[i];
|
|
while (c.charAt(0) == ' ') {
|
|
c = c.substring(1);
|
|
}
|
|
if (c.indexOf(name) == 0) {
|
|
return c.substring(name.length, c.length);
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
function setCookie(cname, cvalue, exdays) {
|
|
const d = new Date();
|
|
d.setTime(d.getTime() + (exdays*24*60*60*1000));
|
|
let expires = "expires="+ d.toUTCString();
|
|
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
|
}
|
|
|
|
function getcartid(){
|
|
cartid = getCookie('cartid');
|
|
//console.log(cartid);
|
|
if (cartid == null || cartid == ""){
|
|
//console.log("not there");
|
|
$.post(
|
|
"/cart/create",
|
|
{'check': "167209"},
|
|
function (data) {
|
|
if (data) {
|
|
setCookie("cartid",data, 180);
|
|
document.getElementById("gcartid").innerHTML = data;
|
|
cartid = data;
|
|
}
|
|
}
|
|
);
|
|
}else{
|
|
document.getElementById("gcartid").innerHTML = cartid;
|
|
//console.log("there");
|
|
}
|
|
return cartid
|
|
}
|
|
|
|
window.onload = function WindowLoad(event) {
|
|
cartid = getcartid();
|
|
console.log(cartid)
|
|
if (typeof getcart === "function"){
|
|
//console.log("isfunction")
|
|
getcart(cartid);
|
|
}
|
|
if (typeof getcartcheckout === "function"){
|
|
//console.log("isfunction2")
|
|
getcartcheckout(cartid);
|
|
}
|
|
}
|