Skip to content

Instantly share code, notes, and snippets.

View Juanpablobar's full-sized avatar

Juan Pablo Barrios Juanpablobar

View GitHub Profile
@Juanpablobar
Juanpablobar / vtex-apis.js
Created September 27, 2022 00:42
VTEX API's
//Información de sessions (regionId, cookies, auth, stores, etc)
const sessions = '/api/sessions/?items=*'
@Juanpablobar
Juanpablobar / setRegionId
Created September 27, 2022 00:38
Set Region ID
fetch("/api/sessions/", {
method: 'PATCH',
headers: {
"Content-Type":"application/json"
},
body: JSON.stringify({
"public": {
"regionId": {
"value": btoa("SW#"+`${account}0127;${account}0178;chedrauimxdarkstore`)
}
@Juanpablobar
Juanpablobar / regex.txt
Created May 3, 2022 21:50
REGEX: Expresiones Regulares
Coincidencias Basicas
. - Cualquier Caracter, excepto nueva linea
\d - Cualquier Digitos (0-9)
\D - No es un Digito (0-9)
\w - Caracter de Palabra (a-z, A-Z, 0-9, _)
\W - No es un Caracter de Palabra.
\s - Espacios de cualquier tipo. (espacio, tab, nueva linea)
\S - No es un Espacio, Tab o nueva linea.
Limites
@Juanpablobar
Juanpablobar / graphQL-query-js.js
Last active August 22, 2022 21:59
VTEX: graphQL query with JS
const resolveURLGraphql = () => {
let graphql = ''
const isProduction = vtex?.renderRuntime?.production
let vtexapi = `https://${vtex.renderRuntime.query.origin}`
if (isProduction) {
graphql = `${vtexapi}/_v/segment/graphql/v1`
} else {
graphql = `${vtexapi}/_v/private/graphql/v1`
}
@Juanpablobar
Juanpablobar / set-get-localStorage.js
Created April 23, 2022 06:07
JS: Set & Get localStorage
const setLocalStorage = () => {
if(typeof localStorage !== "undefined"){
try{
localStorage?.setItem("", JSON.stringify(data));
}catch(e){
console.error(e);
}
}
}
@Juanpablobar
Juanpablobar / subscribe-checkout-events.js
Last active April 23, 2022 05:47
VTEX: Subscribe checkout steps
vtex.events.subscribe('checkoutSteps', (currentView) => {
// profile, shipping, payment
})
@Juanpablobar
Juanpablobar / checkout-events.js
Last active October 7, 2023 01:25
VTEX: Checkout events
$(window).on('orderFormUpdated.vtex', (event, orderForm) => console.log("orderFormUpdated.vtex"));
$(window).on('orderFormUpdated.vtex', (event, orderForm) => console.log("orderFormUpdated.vtex"));
$(window).on('checkoutRequestEnd.vtex', (event, orderForm) => console.log("checkoutRequestEnd.vtex"));
$(window).on('checkout.vtex.com', (event, orderForm) => console.log("checkout.vtex.com "));
$(window).on('.vtexIdUI', (event, orderForm) => console.log(".vtexIdUI"));