Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

SureCart hook GP Premium

  • 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.

  • 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.

  • Hi Alvind,

    Perfect !

    Thanks.

  • You’re welcome!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.