Created
June 17, 2019 17:02
-
-
Save karen-white/086a6e7bbe1212cbb467671cd1db629c 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
<script> | |
function generateMarkup() { | |
const confirmation = document.querySelector('.orderConfirmation-section:last-of-type'); | |
confirmation.innerHTML += `<div id="shippingMap" > | |
<h2 id="mapHeader" style="margin-bottom: 15px;">We're sending your order to:</h3> | |
{{#if customer}} | |
<a href="/account.php?action=order_status" style="display:block;">Check my order status</a> | |
{{/if}} | |
<iframe id="map" width="450" height="300" ></iframe> | |
</div>`; | |
createIframeSrc(); | |
} | |
function createIframeSrc() { | |
const shipping = JSON.parse(localStorage.shippingAddress); | |
const street = shipping.address1 + ', '; | |
const city = shipping.city + ', '; | |
const state = shipping.stateOrProvince; | |
const fullAddress = street.concat(city, state); | |
const q = encodeURIComponent(fullAddress); | |
document.getElementById('map').setAttribute("src", 'https://www.google.com/maps/embed/v1/place?key=YOUR_GOOGLE_API_KEY=' + q); | |
} | |
setTimeout(generateMarkup, 1000); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment