-
Anonymous
Hello,
What’s the best way to load this SureCart code with GeneratePress Premium only on the SureCart order page so that this code doesn’t load on all pages of the website? Is it possible to load this code with a hook in GeneratePress Premium without using CodeSnippets or WPCode? Do I need to modify the code to use it in a hook on GeneratePress Premium?
Thanks.
-
Alvind
Hi there,
Yes, you can add the code using a Hook Element. Create a new Hook Element and paste this part of the snippet only:
<script> window.addEventListener('appload', (event) => { const addressElement = document.querySelector('sc-order-shipping-address') .shadowRoot.querySelector('sc-address, sc-compact-address'); const select = addressElement.shadowRoot.querySelector('sc-select'); // set a default. select.value = 'YOUR_COUNTRY_CODE'; // limit choices: select.choices = [{ value: 'YOUR_COUNTRY_CODE', label: 'YOUR_COUNTRY_NAME' }]; }); </script>
In the Hook option, select
wp_footer
. To ensure the code only loads on the order page, use the Display Rules section, select Page, and choose the specific order page. -
Anonymous
Hi Alvind,
Perfect !
Thanks.
-
Alvind
You’re welcome!
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.