Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi all,
I'm a developer building a custom theme and I'm adding in a "map" section using google maps with a user provided API key. I'm getting an error related to "this.googlePaySDK.payments" line inside the "payment-sheet" asset from shopify itself.
It seems to break the dynamic add to cart buttons throughout the site. I thought it was related to me using the new google maps importLibrary but I get this error when I'm using the legacy script tag as well.
The code in question is located in theme.liquid:
{% if settings.google_maps_api_key != blank %}
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({ key: "{{ settings.google_maps_api_key }}" });</script>
{% endif %}
It is copied directly from Google documentation. Has anyone run into this before?
And before suggested: no, I do not want to use an iframe.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025