AndreiGh Posted March 26, 2022 Share Posted March 26, 2022 Hello, At the moment of $(document).ready(..., the Cart is not loaded, below is the page HTML. So the cart is rendered by some next-to-run Javascript. I need to run own Javascript code *after* the Cart has been rendered. How can I do that ? Should I wait after some custom event ? Thank you ! <div class="system-page"> <div id="sqs-cart-root"> <script type="application/json"> {"cart":{...CART_CONTENTS_AS_JSON.}} </script> <div id="sqs-cart-container"></div> </div> </div> Link to comment
Beyondspace Posted March 27, 2022 Share Posted March 27, 2022 9 hours ago, AndreiGh said: Hello, At the moment of $(document).ready(..., the Cart is not loaded, below is the page HTML. So the cart is rendered by some next-to-run Javascript. I need to run own Javascript code *after* the Cart has been rendered. How can I do that ? Should I wait after some custom event ? Thank you ! <div class="system-page"> <div id="sqs-cart-root"> <script type="application/json"> {"cart":{...CART_CONTENTS_AS_JSON.}} </script> <div id="sqs-cart-container"></div> </div> </div> The following code works fine on my testing $(document).ready(function() { const cart = $('.showOnDesktop .icon--cart[href *="cart"]')[0]; console.log(cart); }) Try and let me know how it goes BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - Lightbox captions only mode) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace 🚀 Learn how to rank new pages on Google in 48 hours! If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
AndreiGh Posted March 27, 2022 Author Share Posted March 27, 2022 (edited) That code retrieves the floating cart icon, not the actual cart contents, on the "cart" page (the products added in the cart, the "checkout" button) <-- these cart HTML is the one I want to modify (the DIVs with class cart-container, cart-summary). Thank you ! Edited March 27, 2022 by AndreiGh Link to comment
Jesiblumen Posted June 8, 2022 Share Posted June 8, 2022 Hi! I am looking to add a floating cart to my site - would love your help if you found a way! Link to comment
creedon Posted June 8, 2022 Share Posted June 8, 2022 Quote I need to run own Javascript code *after* the Cart has been rendered. How can I do that ? Should I wait after some custom event ? A little late with an answer. Let us know how it goes. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment