Created
October 11, 2013 23:36
-
-
Save jeffdrumgod/6943658 to your computer and use it in GitHub Desktop.
Obter cookie do checkout Vtex.
Utiliza função para obter o parâmetro salvo no cookie checkout.vtex.com.
Com este cookie podemos utilizar a api do checkout para adicionar produtos e realizar outras operações no mesmo checkout da sessão do usuário
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* http://stackoverflow.com/questions/979975/how-to-get-the-value-from-url-parameter */ | |
function getQueryParams(qs) { | |
var qs = qs.split("+").join(" "), params = {}, tokens, re = /[?&]?([^=]+)=([^&]*)/g; | |
while (tokens = re.exec(qs)) { | |
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); | |
} | |
return params; | |
} | |
// obtem ID da sessão do checkout | |
function get_VtexCheckout_orderFormId() { | |
if ("undefined" !== typeof $.cookie) { | |
var a = $.cookie("checkout.vtex.com"); | |
if (a !== null) { | |
a = getQueryParams(a); | |
if ("undefined" !== a.__ofid) { | |
return a.__ofid; | |
} | |
} | |
} else { | |
return ""; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment