Last active
May 27, 2021 07:53
-
-
Save stackdumper/1211ce7d285d9f14160a110918910bda to your computer and use it in GitHub Desktop.
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
if (window.location.pathname == "/cart") { | |
fetch("/cart.js") | |
.then((res) => res.json()) | |
.then((t) => JSON.stringify(t.items.map((t) => [t.product_title, t.id, t.quantity]))) | |
.then(JSON.stringify) | |
.then(btoa) | |
.then((qcCartId) => { | |
console.log("QC CART ID", qcCartId); | |
var checkoutButton = document.querySelector("input[name=checkout]"); | |
checkoutButton.setAttribute("name", "quickCheckout"); | |
checkoutButton.setAttribute("type", "button"); | |
checkoutButton.addEventListener("click", () => { | |
console.log("quick checkout!"); | |
window.location.href = `http://localhost:8081/${qcCartId}`; | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment