KifS Posted November 24 Posted November 24 Site URL: https://www.seasailing.org/sea-store/p/mini-camp-advanced Hi - I'm trying to use product add-ons to get people to make small donations when they sign up for individual camp sessions. I created 2 types of donation add-ons and have them on a sample camp page. However, I'd like to add a header and description above add-ons section so people know what they are there for. Any gurus out there have some code suggestions?
paul2009 Posted November 24 Posted November 24 1 hour ago, KifS said: I'd like to add a header and description above add-ons section so people know what they are there for. Can you provide a mockup of what you are trying to achieve? Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.
KifS Posted November 25 Author Posted November 25 Something like this: A little more space with text highlighting what the add-ons are for more clearly.
paul2009 Posted November 25 Posted November 25 Here's some example code, and a screenshot of what it does: The script checks that the Product Detail Page (PDP) contains at least one Product Add-on with "Support" in the title. This will ensure that it only adds the title to the Add-on section if you are promoting the support add-ons. If a "Support" Add-on is found, a new H3 heading is inserted just above the Add-ons with the title "Help us thrive". You should add the following to the Code Injection FOOTER panel: <!-- Add h3 heading above product add-ons on Product Detail Page ----------> <!-- Copyright Soundfocus Digital [https://sf.digital] --------------------> <!-- Use freely in your code injection. Do NOT re-publish. ----------------> <script> document.addEventListener("DOMContentLoaded", function () { const sfPdpSection = document.querySelector('.pdp-product-add-ons'); if (sfPdpSection) { const sfAddOnTitleDiv = Array.from(sfPdpSection.querySelectorAll('.add-on-title')) .find(sfDiv => /support/i.test(sfDiv.textContent)); if (sfAddOnTitleDiv) { const sfCustomDiv = document.createElement('div'); sfCustomDiv.classList.add('custom-add-on-title'); const sfCustomHeading = document.createElement('h3'); sfCustomHeading.textContent = "Help us thrive"; sfCustomDiv.appendChild(sfCustomHeading); sfPdpSection.parentNode.insertBefore(sfCustomDiv, sfPdpSection); } } }); </script> By default, the heading will use the H3 default style. If you want to change this, you can add some CSS to the Custom CSS panel: .custom-add-on-title h3 { } Did this help? Please give feedback by clicking an icon below ⬇️ Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.
SEA_Kif Posted Monday at 09:50 PM Posted Monday at 09:50 PM @paul2009 - somehow I missed this sample code. You are amazing. Thank you!!!! Just what I was looking for! paul2009 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment